#how to bypass integer limit
72 messages · Page 1 of 1 (latest)
Also always state your use case
it doesn't simply stop at that number, it does continue because roblox automatically uses doubles for all its numbers, problem is because the precision is so limited, adding or subtracting 1 will not change the number, so you just use a bigger number to change it
for example bignum exists with is the most precise thing i've seen but the efficiency is a stab in my chest
ngl should probably avoid those unless you know what you're doing
ye and it doesnt support float, thing u dont want on a game probably
that would depend on what you're doing
if you don't know what you're doing just stick with regular doubles and accept the precision issues, its really not that bad and wont affect your game as much as you might think
well personally when I just started I would've liked to make a cool incremental with no "limit" but going with modules like eternitynum or infinitemath for it when just learning is going to desesperate
yep. e303 is plenty for most games. using these number modules just adds complexity you really don't need if its a first project
and if someone really needed more, and knew they needed more, then they would also know what they're doing when they go to use those bigger number modules.
Let’s be frank, even if you need more then you most likely don’t need the accuracy, the only thing I can think off that would require actual accuracy would be some id system, but even then normal numbers are fine (main limit will most likely be the key sizes of datastores/memory stores being capped at 128 utf8 bytes. (so 1e127 is the limit with a normal b10 number) which should be more than plenty for any purpose that I can think if were you need such accuracy
If you want some game with some of those insane stats then you can just write your own version of some number rounding system. As 4 significant figures is all you need at that point, if it isn’t then you need to work on your gameplay loop as the data that gets nullified makes up less than 1 promille of the total, meaning the player would have to repeat a task 1000 times to double his stat
there are no integers in roblox or luau
all numbers are doubles which retain integer precision up to somewhere about 2^53 i believe
if the concern is key lengths for datastores then stop worrying about it
if you just want to have big numbers like in a tycoon then i believe there are bigint libraries available
There are integers used in roblox
OrderedDataStores
Values must be positive integers only
IntValue, and idk what else accepts integers strictly
Buffers also differentiate between floats, unsigned and signed integers
thanks
intvalues store integers but not really; all reads of intvalue.Value give you a double
ordereddatastore only do because it's computationally easier to sort (which is their job)
Hence why I said roblox not luau
even in roblox a 64-bit integer can never exist in a luau VM register
the format IntValue uses to store integers is more of an implementation detail than it is something that is relevant to you as a programmer
same for OrderedDataStore keys and values
and anywhere else you can find an actual physical integer value, probably
for any and all intents and purposes, integers do not exist in luau code nor roblox code
for the sake of this discussion, i define "bigint" as "any integer which fits inside a 64-bit physical integer representation but not in an IEEE754 double"
i can't discover any way to write a bigint to an IntValue from luau code
additionally, even if such a bigint is written to an IntValue from the properties window, it still doesn't exist, because any read of this value causes the same precision loss
because luau code / any user-created roblox code (scripts) cannot in any way even conceptualize integers above 2^53 or whereever the exact cutoff is
the number datatype is a double
it is a sixteen byte VM register value where eight of those bytes are used to represent an IEEE 754 64-bit floating point number
the only way a true 64 bit integer could exist in user-created code would be through that users location, implementation, or through any method access of a bigint library which uses strings, buffers, or any data structure that must consist of more bytes than a single number value
but that's not a primitive, and any turing complete language can do anything if you try hard enough
well, i suppose using more bytes would not be strictly necessary, but it'll certainly not achieve it through the use of a single number value itself
** You are now Level 3! **
Don't think too deep into it, when I said that integers are used, I am quite literally talking about the how roblox does differentiate from int64, int, and float number classes. Yes they are all stored as IEE754, but when I say that integers exist, I am talking about how roblox does distinguish between them in the reference manual
** You are now Level 6! **
this distinguishment is about how those api calls don't expect numbers with decimal values
not about how many bits of integer precision they have
Yes but all I mean is that there is a distinguishment
not really lol
for reasons explained above
an integer inside of a double is still a double
it's only an integer in the mathematical sense
it is not an integer in the programmatic sense
Noo you're still overthinking it, yes an integer IS stored as double. But that's not what I mean. I literally am just saying that roblox has things like IntValues, that only accept "integers" (think of the integer set of numbers, 0, 1, 2..., which is represented as a double, but nonetheless is distinguished from NumberValue)
yes
those are mathematical integers
not programmatic integers (not the value you provide to them)
And that's what I'm saying, roblox distinguishes between the integer set and real number set (leaving luau completely out of it)
but we're not programming the engine, are we?
we're programming in luau
and we can only do what luau can do
We are using it, and the engine gives us the option of IntValue, or NumberValue, and not NumberValue only
the only real usecase of IntValue is for cross-trust communication to ensure that the number read is a mathematical integer
i see no benefits except in perhaps the wackiest of niches that would never realistically happen for it to be in any way relevant that IntValue stores physically as a programmatic integer
Again don't think too deep into it, it exists and that's all that matters
yeah but where does its existence come into play
where does its existence invalidate the functional correctness of "there are no integers in roblox or luau"
no matter what you can't have an integer, it is forbidden
any sensible human wouldn't hit 2^52 much less 2^64 keys in an ordereddatastore and if the values themselves exceed that number then you need to rework your system because you can't even handle player save data anymore