标签: javascript floating-point precision
Number.MAX_SAFE_INTEGER = 9007199254740991 link
Number.MAX_SAFE_INTEGER = 9007199254740991
1000000000000 === 999999999999.999999 // Gives output true 1000000000000 === 999999999999.99999 // Gives output true 1000000000000 === 999999999999.9999 // Gives output false
任何线索为什么会这样?
答案 0 :(得分:1)
因为浮点精度低。
http://en.wikipedia.org/wiki/Floating-point