yma@kicon.com (chirs) writes:
[color=blue]
> 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.[/color]
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:
0xfffffffffffff80000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000
(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
0xfffffffffffffbffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffff
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
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'