This simple package formats Float numbers as pretty strings. It is
flexible enough to deal with different number of decimals, different thousand
separators and different decimal separator.
It also humanizes decimals numbers with different strategies for handling zeros:
Humanize the decimal part of a float with different strategies to remove tail zeros:
import FormatNumber exposing (humanize)
import FormatNumber.Humanize exposing (ZeroStrategy(..))
import FormatNumber.Locales exposing (usLocale)
humanize usLocale RemoveZeros 10.00
--> "10"
humanize usLocale RemoveZeros 10.10
--> "10.1"
humanize usLocale KeepZeros 10.00
--> "10"
humanize usLocale KeepZeros 10.10
--> "10.10"Int numbers?Just convert them to Float before passing them to format:
>>> import FormatNumber.Locales exposing (usLocale)
>>> format usLocale (toFloat 1234)
"1,234.00"
>>> import FormatNumber.Locales exposing (usLocale)
>>> format { usLocale | decimals = 0 } <| toFloat 1234
"1,234"
Format a float number as a pretty string: