#how to bypass integer limit

72 messages · Page 1 of 1 (latest)

royal violet
#

seems like roblox stops at 9223372036854775295 on the dot which is 2 to the 63rd - 1 - 512
is there any way to bypass that?
in an int variable it stores 2 to the 63rd - 1024

craggy finch
#

modules like eternitynum, infinite math

#

check those out

opaque pollen
#

Also always state your use case

drifting trail
#

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

craggy finch
drifting trail
craggy finch
#

ye and it doesnt support float, thing u dont want on a game probably

drifting trail
#

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

craggy finch
#

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

drifting trail
#

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.

gloomy shadow
# drifting trail yep. e303 is plenty for most games. using these number modules just adds complex...

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

plucky river
#

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

opaque pollen
#

OrderedDataStores

#

Values must be positive integers only

#

IntValue, and idk what else accepts integers strictly

gloomy shadow
royal violet
#

thanks

plucky river
#

ordereddatastore only do because it's computationally easier to sort (which is their job)

opaque pollen
plucky river
#

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

plucky river
somber hatchBOT
#

studio** You are now Level 3! **studio

opaque pollen
#

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

somber hatchBOT
#

studio** You are now Level 6! **studio

plucky river
#

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

opaque pollen
#

Yes but all I mean is that there is a distinguishment

plucky river
#

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

opaque pollen
#

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)

plucky river
#

yes

#

those are mathematical integers

#

not programmatic integers (not the value you provide to them)

opaque pollen
#

And that's what I'm saying, roblox distinguishes between the integer set and real number set (leaving luau completely out of it)

plucky river
#

but we're not programming the engine, are we?

#

we're programming in luau

#

and we can only do what luau can do

opaque pollen
plucky river
#

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

opaque pollen
#

Again don't think too deep into it, it exists and that's all that matters

plucky river
#

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