Number value - inf num problem

so my game is rebirth simulator 2.0 and it is basically about numbers but the problem is that when i go more than 1e300 it changes to inf, how do i fix it

2 ** 1024 (1e308 approximately) or higher than that will return infinity for a double value. You’ve passed the max value of a double thus it returns infinity.

#include <stdio.h>
#include <float.h>
#include <math.h>

int main()
    printf("%f\n%f", DBL_MAX, pow(2.0, 1024));

    return 0;



Use BigInt/BigNum if you want to fix that (and you’re not using decimals) but there isn’t a BigIntValue.

@Blockzez He is talking about lua not C++.

Lua 5.1 uses double as a number. This applies to NumberValue.

NumberValue uses a double precision floating point (basically in Lua’s term number) value which can store up to 2 ** 1024 (1e308) (though some precision will be lost). double values can go up to 2 ** 1024. tonumber function converts it to double so it’ll still return infinity.

tonumber('1' .. ('0'):rep(308)) --> inf

Strings could work for converitng it to BigInt though.

this post is irrelevant to the problem and your not really giving a solution.

The title:

Number value - inf num problem

How is it irrelevant to the problem? The OP clearly stated the problem is about the NumberValue (not IntValue) turning to infinity. Lua number can only store up to 10e307. BigInt/BigNum serialising to strings and vice versa is (probably) the soultion, it can handle large values without turning it to infinity.


The code was unnecessary, btw here is a link to a BigNum module you can use:BigNum - RoStrap

I know but he probably has no idea what int main() { … } or #include <…h> is LOL.