Cldr v0.0.17 Cldr.Number.Formatter.Short
Formats a number according to the locale-specific :short
formats
This is best explained by some examples:
iex> Cldr.Number.to_string 123, format: :short
"123"
iex> Cldr.Number.to_string 1234, format: :short
"1K"
iex> Cldr.Number.to_string 523456789, format: :short
"523M"
iex> Cldr.Number.to_string 7234567890, format: :short
"7B"
iex> Cldr.Number.to_string 7234567890, format: :long
"7 billion"
These formats are compact representations however they do lose precision in the presentation in favour of human readibility.
Note that for a :currency
short format the number of decimal places
is retrieved from the currency definition itself. You can see the difference
in the following examples:
iex> Cldr.Number.to_string 1234, format: :short, currency: "EUR"
"€1K"
iex> Cldr.Number.to_string 1234, format: :short, currency: "EUR", fractional_digits: 2
"€1.23K"
iex> Cldr.Number.to_string 1234, format: :short, currency: "JPY"
"¥1K"