在ECMAScript Internationalization API 1.0 规范中,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 规范?想不出别的了……</p>