Intl.NumberFormat #format格式的最大整数值

时间:2015-01-30 05:54:11

标签: javascript internationalization number-formatting ecmascript-intl

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规范?想不出别的......

1 个答案:

答案 0 :(得分:2)

  

ES5规范遵循IEEE 754规范

ECMAScript Intl API规范引用了基本类型的ES5规范。