Reputation: 19
look at this picture.(The underLine is input.)
why the end of JavaScript Number with trailing zeros or a not predictable number?
I checked the document with https://www.ecma-international.org/ecma-262/5.1/#sec-9.7
But I can't find anything useful for this problem.
Upvotes: 0
Views: 965
Reputation: 471
Numbers in Javascript use Double-precision floating-point format which can represent numbers from -(2^53 - 1) and (2^53 - 1). This limits the maximum safe number (Number.MAX_SAFE_INTEGER) to 9007199254740991.
Hence any number above that will be not be represented accurately.
Upvotes: 1
Reputation: 6914
so the thing is there is maximum integer which can be safely manipulated in javascript after that you are supposed to get some unexpected results based on implementation
read about that max safe integer https://www.ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer
BTW there is a new bigint
type which can handle large numbers https://developers.google.com/web/updates/2018/05/bigint
bigint however is not a standard yet i think
Upvotes: 0