Why is 9999999999999999 converted to 10000000000000000 in JavaScript?

后端 未结 5 2097
遥遥无期
遥遥无期 2020-11-30 03:45

Can any one explain to me why 9999999999999999 is converted to 10000000000000000?

alert(9999999999999999); //10000000000000000

http://jsfid

5条回答
  •  时光说笑
    2020-11-30 04:37

    Javascript doesn't have integers, only 64-bit floats - and you've ran out of floating-point precision.

    See similar issue in Java: why is the Double.parseDouble making 9999999999999999 to 10000000000000000?

提交回复
热议问题