ggb / numeral-elm

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

Fix: Inconsistent results with scientific notation or very small numbers #20

Open soad003 opened 1 year ago

soad003 commented 1 year ago

The issue (#18) was the implementation of String.fromFloat in the core lib of elm. It is implemented as js function doing the following float_value + '' to convert the float to a string. This formats tiny numbers in scientific notation which is not expected in elm-numeral.

3.367e-7 + '' == '3.367e-7'

I fixed it by using the toDecimal function of myrho/elm-round which does not have this behavior for small values.