Numeral-js
Numeral-js copied to clipboard
formating a number which is very very small will get NaN
import numeral from 'numeral';
console.log(
'numeral',
numeral('-0.0000000008851743227289433')
.divide(0.01)
.format('0.0'),
numeral('-0.000000009433')
.divide(0.01)
.format('0.0'),
);
// numeral NaN 0.0
+1, I am facing the same issue when try to enter long integer (more than 22 digit.) Ex: 12345678901234567890123
numbro(-0.00000000008851743227289433).format()
// "-8.851743227289433e-11"
numbro(12345678901234567890123).format()
// "1.2345678901234568e+22"
Maybe numbro is worth a try?
Disclosure: I'm numbro author