View Source Number.Human (number v1.0.5)
Provides functions for converting numbers into more human readable strings.
Summary
Functions
Formats and labels a number with the appropriate English word.
Adds ordinal suffix (st, nd, rd or th) for the number
Functions
Formats and labels a number with the appropriate English word.
Examples
iex> Number.Human.number_to_human(nil)
nil
iex> Number.Human.number_to_human(123)
"123.00"
iex> Number.Human.number_to_human(1234)
"1.23 Thousand"
iex> Number.Human.number_to_human(999001)
"999.00 Thousand"
iex> Number.Human.number_to_human(1234567)
"1.23 Million"
iex> Number.Human.number_to_human(1234567890)
"1.23 Billion"
iex> Number.Human.number_to_human(1234567890123)
"1.23 Trillion"
iex> Number.Human.number_to_human(1234567890123456)
"1.23 Quadrillion"
iex> Number.Human.number_to_human(1234567890123456789)
"1,234.57 Quadrillion"
iex> Number.Human.number_to_human(Decimal.new("5000.0"))
"5.00 Thousand"
iex> Number.Human.number_to_human('charlist')
** (ArgumentError) number must be a float, integer or implement `Number.Conversion` protocol, was ~c"charlist"
Adds ordinal suffix (st, nd, rd or th) for the number
Examples
iex> Number.Human.number_to_ordinal(3)
"3rd"
iex> Number.Human.number_to_ordinal(1)
"1st"
iex> Number.Human.number_to_ordinal(46)
"46th"
iex> Number.Human.number_to_ordinal(442)
"442nd"
iex> Number.Human.number_to_ordinal(4001)
"4001st"