Numeral-js: numeral format for small numbers returns NaN

Created on 20 Mar 2018  路  8Comments  路  Source: adamwdraper/Numeral-js

For example numeral(0.0000000048).format('0') // NaN

Most helpful comment

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

All 8 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rvanmil picture rvanmil  路  4Comments

MisterGoodcat picture MisterGoodcat  路  3Comments

chumager picture chumager  路  3Comments

tab00 picture tab00  路  8Comments

ragulka picture ragulka  路  6Comments