How can I handle numbers bigger than 17-digits in Firefox/IE7?(如何在 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 位的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Firefox/IE7 中处理大于 17 位的数字?


基础教程推荐
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01