What is the maximum number in JavaScript? I tried a large number like
0xff...ff with 30 fs, it still gives me a number, not an infinity. I
use IE6.
Javascript uses IEEE-754 double precission floating point numbers.
From the ECMAScript standard:
---
... of them are normalised, having the form
s × m × 2^e
where s is +1 or -1, m is a positive integer less than 2^53 but not less
than 2^52, and e is an integer ranging from -1074 to 971, inclusive.
---
That means that the maiximal number representable as a Javascript number
is
1 * (2^53-1) * 2^971 == 2^1024 - 2^971
In hexadecimal, that is:
0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
(256 hexadecimal digits)
Writing that hexadecimal number into Javascript, makes it output this
notation:
1.7976931348623157e+308
If you add one more bit, changing the "8" to a "c" in the hexadecimal
notation, Javascript gives "Infinity". Only that bit matters, changing
later bits is simply ignored. That is
0xfffffffffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
gives the same result as the above, because all the extra one-bits are
lost due to lack of precission, and they are rounded down.
/L