1. <legend id='rcGWi'><style id='rcGWi'><dir id='rcGWi'><q id='rcGWi'></q></dir></style></legend>
      <tfoot id='rcGWi'></tfoot>
          <bdo id='rcGWi'></bdo><ul id='rcGWi'></ul>

        <small id='rcGWi'></small><noframes id='rcGWi'>

        <i id='rcGWi'><tr id='rcGWi'><dt id='rcGWi'><q id='rcGWi'><span id='rcGWi'><b id='rcGWi'><form id='rcGWi'><ins id='rcGWi'></ins><ul id='rcGWi'></ul><sub id='rcGWi'></sub></form><legend id='rcGWi'></legend><bdo id='rcGWi'><pre id='rcGWi'><center id='rcGWi'></center></pre></bdo></b><th id='rcGWi'></th></span></q></dt></tr></i><div id='rcGWi'><tfoot id='rcGWi'></tfoot><dl id='rcGWi'><fieldset id='rcGWi'></fieldset></dl></div>

        JavaScript 是否支持 64 位整数?

        时间:2023-09-07
      1. <legend id='lLVEw'><style id='lLVEw'><dir id='lLVEw'><q id='lLVEw'></q></dir></style></legend>
          <bdo id='lLVEw'></bdo><ul id='lLVEw'></ul>
        • <tfoot id='lLVEw'></tfoot>

            <tbody id='lLVEw'></tbody>

                <small id='lLVEw'></small><noframes id='lLVEw'>

                <i id='lLVEw'><tr id='lLVEw'><dt id='lLVEw'><q id='lLVEw'><span id='lLVEw'><b id='lLVEw'><form id='lLVEw'><ins id='lLVEw'></ins><ul id='lLVEw'></ul><sub id='lLVEw'></sub></form><legend id='lLVEw'></legend><bdo id='lLVEw'><pre id='lLVEw'><center id='lLVEw'></center></pre></bdo></b><th id='lLVEw'></th></span></q></dt></tr></i><div id='lLVEw'><tfoot id='lLVEw'></tfoot><dl id='lLVEw'><fieldset id='lLVEw'></fieldset></dl></div>

                  本文介绍了JavaScript 是否支持 64 位整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有以下代码:

                  var str = "0x4000000000000000";   //4611686018427387904 decimal
                  var val = parseInt(str);
                  alert(val);
                  

                  我得到这个值:4611686018427388000",即0x4000000000000060

                  我想知道 JavaScript 是否错误地处理了 64 位整数,还是我做错了什么?

                  I was wondering if JavaScript is mishandling 64-bit integers or am I doing something wrong?

                  推荐答案

                  JavaScript 使用 IEEE- 表示数字754 双精度(64 位)格式.据我了解,这为您提供了 53 位精度,或 15 到 16 个十进制数字.你的数字比 JavaScript 处理的数字多,所以你最终得到一个近似值.

                  JavaScript represents numbers using IEEE-754 double-precision (64 bit) format. As I understand it this gives you 53 bits precision, or fifteen to sixteen decimal digits. Your number has more digits than JavaScript can cope with, so you end up with an approximation.

                  这并不是真正的错误处理",但如果您需要对大数进行完全精确处理,显然它不是很有帮助.有一些 JS 库可以处理更大的数字,例如 BigNumber 和 Int64.

                  This isn't really "mishandling" as such, but obviously it isn't very helpful if you need full precision on large numbers. There are a few JS libraries around that can handle larger numbers, e.g., BigNumber and Int64.

                  这篇关于JavaScript 是否支持 64 位整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何解决 JavaScript 的 parseInt 八进制行为? 下一篇:检查数字是否有小数位/是否为整数

                  相关文章

                  最新文章

                  <small id='4rk6X'></small><noframes id='4rk6X'>

                    <tfoot id='4rk6X'></tfoot>
                      <bdo id='4rk6X'></bdo><ul id='4rk6X'></ul>

                    1. <legend id='4rk6X'><style id='4rk6X'><dir id='4rk6X'><q id='4rk6X'></q></dir></style></legend>
                    2. <i id='4rk6X'><tr id='4rk6X'><dt id='4rk6X'><q id='4rk6X'><span id='4rk6X'><b id='4rk6X'><form id='4rk6X'><ins id='4rk6X'></ins><ul id='4rk6X'></ul><sub id='4rk6X'></sub></form><legend id='4rk6X'></legend><bdo id='4rk6X'><pre id='4rk6X'><center id='4rk6X'></center></pre></bdo></b><th id='4rk6X'></th></span></q></dt></tr></i><div id='4rk6X'><tfoot id='4rk6X'></tfoot><dl id='4rk6X'><fieldset id='4rk6X'></fieldset></dl></div>