如何在Firefox/IE7中处理大于17位的数字? [英] How can I handle numbers bigger than 17-digits in Firefox/IE7?

查看:54
本文介绍了如何在Firefox/IE7中处理大于17位的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Web应用程序,我希望能够处理最大64位的数字. 在测试过程中,我发现javascript(或整个浏览器)似乎可以处理多达17位数字. 64位数字最多可包含20位数字,但是在javascript处理完该数字后,最低有效3位数字将四舍五入并设置为0.... 有什么想法吗? 更重要的是,您知道如何解决此问题吗?

For a web application I want to be able to handle numbers up to 64 bits in size. During testing, I found that javascript (or the browser as a whole) seems to handle as much as 17 digits. A 64-bit number has a maximum of 20 digits, but after the javascript has handled the number, the least significant 3 digits are rounded and set to 0.... Any ideas where this comes from? More importantly, any idea how to work around it?

推荐答案

在Javascript中,所有数字均为 IEEE double精度浮点数,这意味着您只有约16位数字的精度; 64位的其余部分保留给指数.如Fabien所述,如果需要全部64位,您将需要一些技巧来获得更高的精度.

In Javascript, all numbers are IEEE double precision floating point numbers, which means that you only have about 16 digits of precision; the remainder of the 64 bits are reserved for the exponent. As Fabien notes, you will need to work some tricks to get more precision if you need all 64 bits.

这篇关于如何在Firefox/IE7中处理大于17位的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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