为什么9999999999999999在JavaScript中转换为10000000000000000? [英] Why is 9999999999999999 converted to 10000000000000000 in JavaScript?

查看:438
本文介绍了为什么9999999999999999在JavaScript中转换为10000000000000000?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我解释为什么9999999999999999被转换为10000000000000000?

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

alert(9999999999999999); //10000000000000000

http://jsfiddle.net/Y2Vb2/

推荐答案

Javascript没有整数,只有64位浮点数 - 而且你已经没有浮点精度了。

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

在Java中看到类似的问题:为什么Double.parseDouble使9999999999999999变为10000000000000000?

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

这篇关于为什么9999999999999999在JavaScript中转换为10000000000000000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆