For the technically curious, you need to use a table implementation to represent a number beyond 64 bits, where each index of the table represents a radix (places in a number).
That’s what this module does.
As a side effect however, this consumes significantly more memory. Use with care.
oh sorry i didnt clarify it.
The Currency also cant be more than 9.2Qn, so there is no chance of buying a button costin more.
Also the Currency resets once the 9.2Qn is reached
You clearly don’t know how buffers work. A “buffer” is a chunk of memory that can have any size. You can write with offsets to simulate larger numbers.
Make a buffer with the size of 8 bytes buffer.create(8)
Write to offsets (0, 4) with buf.writeu32()
To make a 128 bit integer;
Make a buffer with the size of 16 bytes buffer.create(16)
Write to offsets (0, 4, 8, 12) with buf.writeu32()
Theoretically you can do this until you have no memory left.
Yes your math is correct, but we aren’t combining two 64 bit integers. We are using every bit as a power of 2.
This doesn’t work though. You can’t read 128 bit integers from a buffer with the current buffer implementation and writing 4 32 bit integers is not the same as writing one 128 bit integer.
The only way this works is by combining the numbers in series which has far less flexibility than a 128 bit integer.
It technically is because 4 chunks of 32 bit memory is just 128 bits. You just need to interpolate the offset bytes and add it to your number correctly. (basically chunk_value * (2 ^ chunk_offset))
And yes, you’re right, this is not a native 128 bit integer class so it won’t be as optimized as say 32 bit integers. But in this use case, it should work just fine.