javascript tutorial - [Solved-5 Solutions] What is javascript’s highest integer value that a number can go to without losing precision ? - javascript - java script - javascript array
Problem:
Is this defined by the language? Is there a defined maximum ? Is it different in different browsers ?
Solution 1:
They are 64-bit floating point values, the largest exact integral value is 253-1, or 9007199254740991. In ES6, this is defined as Number MAX_SAFE_INTEGER. Note that the bitwise operators and shift operators operate on 32-bit ints, so in that case, the max safe integer is 231-1, or 2147483647. Test it out!
Solution 2:
From the reference: alert([Number.MAX_VALUE, Number.MIN_VALUE]);
Solution 3:
It is 253 == 9 007 199 254 740 992. This is because Numbers are stored as floating-point in a 52-bit mantissa. The min value is -253. This makes some fun things happening
And can also be dangerous :)
Solution 4:
In javascript, there is a number called Infinity examples:
Solution 5:
ECMAScript 6: