cuducos/elm-format-number/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

FormatNumber

This simple package formats numbers as pretty strings. It is flexible enough to deal with different number of decimals, different thousand separators and diffetent decimal separator.

Usage

formatFloat : Int -> String -> String -> Float -> String

Format a float number as a pretty string. The four arguments are: number of decimals, thousand separator, decimal separator and the float number itself.

>>> formatFloat 2 "," "." 1234.5567
"1,234.56"


>>> formatFloat 3 "." "," -7654.3210
"-7.654,321"


>>> formatFloat 1 "," "." -0.01
"0.0"
formatInt : Int -> String -> String -> Int -> String

Format a float number as a pretty string. The four arguments are: number of decimals, thousand separator, decimal separator and the float number itself. >>> formatInt 1 "," "." 0 "0.0"

>>> formatInt 1 "," "." 1234567890
"1,234,567,890.0"