Open meafmira opened 6 years ago
Same issue, appears to be any number with 6 or more leading 0s.
numeral(.0000001).format('0')
> "NaN"
numeral(.000001).format('0')
> "0"
numeral(.0000005).format('0')
> "NaN"
numeral(.0000009).format('0')
> "NaN"
numeral(.0000010).format('0')
> "0"
numeral(.0000015).format('0')
> "0"
Incidentally, that appears to be when the chrome console starts displaying numbers in exponential form.
.000001
> 0.000001
.0000001
> 1e-7
I downgraded to 1.5.6 to avoid this bug.
Is this duplicate of #512 ?
Same for large and exponential number format.
As a workaround I suggest downgrade to 2.0.4 2.0.6: https://jsfiddle.net/xkp1wmb4/ 2.0.4: https://jsfiddle.net/d9pfv4na/2/
I've seen at least three PRs in the queue addressing this issue
Still baffled that the PR's fixing this have not been merged
Still baffled that the PR's fixing this have not been merged
Unfortunately the last commit was 4 years ago. The author probably doesn't have time any more for this project.
since this repo is not updated anymore, and still have this bug, and if you still wish to use the latest version, you can do this work around:
function formatSmall(val, format) {
if (val > 0 && val < 1e-6){
// make the number 100 times greater, then just replace 0.0 with additional 2 zeroes (from 100)
return numeral(val * 100).format(format).replace('0.0', '0.000');
}
return numeral(val).format(format);
}
For example
numeral(0.0000000048).format('0') // NaN