Search code examples
javascriptinternationalizationnumber-formattingecmascript-intl

Intl.NumberFormat#format maximum integer value


In ECMAScript Internationalization API 1.0 spec, NumberFormat object has a format function which takes in a value and formats the number according to NumberFormat object.

What is the maximum value NumberFormat#format function can digest?

In Chrome, and Firefox running below:

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

It seems that anything after 15th digit is converted to 0. I had a quick look at the spec, but couldn't figure out why. Does anyone know why?

Maybe because the above ES5 spec follows IEEE 754 specification? Can't think of anything else…


Solution

  • ES5 spec follows IEEE 754 specification

    And the ECMAScript Intl API specification refers to ES5 spec for base types.