【问题标题】:Intl.NumberFormat#format maximum integer valueIntl.NumberFormat#format 最大整数值
【发布时间】:2015-01-30 05:54:10
【问题描述】:

ECMAScript Internationalization API 1.0 spec中,NumberFormat对象有一个format函数,它接受一个值并根据NumberFormat对象格式化数字。

NumberFormat#format函数可以消化的最大值是多少?

在 Chrome 和 Firefox 下运行:

new Intl.NumberFormat().format(1111111111111111);
// => "1,111,111,111,111,110"
//                         ^
//                     16th digit

似乎第 15 位之后的任何内容都转换为 0。我快速浏览了规范,但不知道为什么。有谁知道为什么?

可能是因为上述 ES5 规范遵循 IEEE 754 规范?想不出别的了……

【问题讨论】:

    标签: javascript internationalization number-formatting ecmascript-intl


    【解决方案1】:

    ES5 规范遵循 IEEE 754 规范

    ECMAScript Intl API 规范参考了 ES5 规范的基本类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      • 2011-05-25
      • 2012-04-09
      • 1970-01-01
      • 2012-11-20
      • 2012-08-09
      • 2019-08-15
      相关资源
      最近更新 更多