MyApp.Cldr.Number.System.to_system
to_system
, go back to MyApp.Cldr.Number.System module for more information.
Converts a number into the representation of a non-latin number system.
This function converts numbers to a known number system only, it does not provide number formatting.
number
is afloat
,integer
orDecimal
system_name
is any number system name returned byCldr.known_number_systems/0
or a number system type returned byCldr.known_number_system_types/0
There are two types of number systems in CLDR:
:numeric
in which the number system defines a direct mapping between the latin digits0..9
into a the number system equivalent. In this case,to_system/2
invokesCldr.Number.Transliterate.transliterate_digits/3
for the given number.:algorithmic
in which the number system does not have the same structure as the:latn
number system and therefore the conversion is done algorithmically. For CLDR the algorithm is implemented throughCldr.Rbnf
rulesets. These rulesets are considered by CLDR to be less rigorous than the:numeric
number systems and caution and testing for a specific use case is recommended.
Examples
iex> MyApp.Cldr.Number.System.to_system 123456, :hebr
{:ok, "קכ״ג׳תנ״ו"}
iex> MyApp.Cldr.Number.System.to_system 123, :hans
{:ok, "一百二十三"}
iex> MyApp.Cldr.Number.System.to_system 123, :hant
{:ok, "一百二十三"}
iex> MyApp.Cldr.Number.System.to_system 123, :hansfin
{:ok, "壹佰贰拾叁"}