ggb / numeral-elm

Numeral.js port to Elm
MIT License
22 stars 9 forks source link

Inconsistent results with scientific notation or very small numbers #18

Open sporto opened 3 years ago

sporto commented 3 years ago

Scientific notation e.g. 3.367e-6 are valid JS and Elm numbers. Sometimes you get that when decoding JSON.

This works as expected

Numeral.format "$0.00000000" 3.367e-6
==
$0.00000337

But this doesn't

Numeral.format "$0.00000000" 3.367e-7
==
-$.4e-70000

Expected $0.00000034

Similar issue with

(Numeral.format "$0.00000000" 0.000000367)
==
-$.7e-70000

Thanks

ggb commented 3 years ago

Thanks for the hint and sorry for the late response: I looked into this issues weeks ago, didn't understand the reasons for this issue and it immediately slipped from my mind ;) Do you have a suggestion on how to fix this issue?