Numeral-js: Parsing issue with 17+ numbers

Created on 17 Sep 2018  路  1Comment  路  Source: adamwdraper/Numeral-js

Version: 2.0.6

There seems to be an issue when using the following function:

const amount = 11111111111111111; // 17 characters
const value = numeral(amount).format('0,0.00');
console.log(value); // outputs "11,111,111,111,111,112.00"

Expected: 11,111,111,111,111,111.00
Actual: 11,111,111,111,111,112.00

This issue will occur when there is 17 or more numbers provided and an incorrect conversion occurs

Most helpful comment

JavaScript does not support such big numbers, the max safe value is:

Number.MAX_SAFE_INTEGER
9007199254740991

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

>All comments

JavaScript does not support such big numbers, the max safe value is:

Number.MAX_SAFE_INTEGER
9007199254740991

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonathanbergson picture jonathanbergson  路  6Comments

chumager picture chumager  路  3Comments

anselms picture anselms  路  4Comments

tony-kerz picture tony-kerz  路  6Comments

GitzJoey picture GitzJoey  路  4Comments