<inputname="q"type="text"class="search-input"placeholder="Search..."aria-label="Input your search terms"autocomplete="off"autocorrect="off"autocapitalize="off"spellcheck="false"/>
<p>Formats numbers and currencies based upon CLDR's decimal formats specification.</p><p>The format specification is documentated in <ahref="http://unicode.org/reports/tr35/tr35-numbers.html#Number_Formats">Unicode TR35</a>.
There are several classes of formatting including non-scientific, scientific,
rules based (for spelling and ordinal formats), compact formats that display <codeclass="inline">1k</code>
rather than <codeclass="inline">1,000</code> and so on. See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.html#to_string/2"><codeclass="inline">Cldr.Number.to_string/2</code></a> for specific formatting
<p>The following description applies to formats that do not use scientific
notation or significant digits:</p><ul><li><p>If the number of actual integer digits exceeds the maximum integer digits,
then only the least significant digits are shown. For example, 1997 is
formatted as "97" if the maximum integer digits is set to 2.</p></li><li><p>If the number of actual integer digits is less than the minimum integer
digits, then leading zeros are added. For example, 1997 is formatted as
"01997" if the minimum integer digits is set to 5.</p></li><li><p>If the number of actual fraction digits exceeds the maximum fraction
digits, then half-even rounding it performed to the maximum fraction
digits. For example, 0.125 is formatted as "0.12" if the maximum fraction
digits is 2. This behavior can be changed by specifying a rounding
increment and a rounding mode.</p></li><li><p>If the number of actual fraction digits is less than the minimum fraction
digits, then trailing zeros are added. For example, 0.125 is formatted as
"0.1250" if the minimum fraction digits is set to 4.</p></li><li><p>Trailing fractional zeros are not displayed if they occur j positions after
the decimal, where j is less than the maximum fraction digits. For example,
0.10004 is formatted as "0.1" if the maximum fraction digits is four or
<p>Numbers in scientific notation are expressed as the product of a mantissa and
a power of ten, for example, 1234 can be expressed as 1.234 x 10^3. The
mantissa is typically in the half-open interval [1.0, 10.0) or sometimes
[0.0, 1.0), but it need not be. In a pattern, the exponent character
immediately followed by one or more digit characters indicates scientific
notation. Example: "0.###E0" formats the number 1234 as "1.234E3".</p><ul><li><p>The number of digit characters after the exponent character gives the
minimum exponent digit count. There is no maximum. Negative exponents are
formatted using the localized minus sign, not the prefix and suffix from
the pattern. This allows patterns such as "0.###E0 m/s". To prefix positive
exponents with a localized plus sign, specify '+' between the exponent and
the digits: "0.###E+0" will produce formats "1E+1", "1E+0", "1E-1", and so
on. (In localized patterns, use the localized plus sign rather than '+'.)</p></li><li><p>The minimum number of integer digits is achieved by adjusting the exponent.
Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This only
happens if there is no maximum number of integer digits. If there is a
maximum, then the minimum number of integer digits is fixed at one.</p></li><li><p>The maximum number of integer digits, if present, specifies the exponent
grouping. The most common use of this is to generate engineering notation,
in which the exponent is a multiple of three, for example, "##0.###E0". The
number 12345 is formatted using "##0.####E0" as "12.345E3".</p></li><li><p>When using scientific notation, the formatter controls the digit counts
using significant digits logic. The maximum number of significant digits
limits the total number of integer and fraction digits that will be shown
in the mantissa; it does not affect parsing. For example, 12345 formatted
with "##0.##E0" is "12.3E3". Exponential patterns may not contain grouping
<divclass="summary-synopsis"><p>Same as the execution of <ahref="#to_string/2"><codeclass="inline">to_string/2</code></a> but raises an exception if an error would be
<ul><li><p><codeclass="inline">string</code> is any <codeclass="inline">String.t</code></p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="parse/2-options"class="section-heading">
<ul><li><p><codeclass="inline">:number</code> is one of <codeclass="inline">:integer</code>, <codeclass="inline">:float</code>,
<codeclass="inline">:decimal</code> or <codeclass="inline">nil</code>. The default is <codeclass="inline">nil</code>
meaning that the type auto-detected as either
an <codeclass="inline">integer</code> or a <codeclass="inline">float</code>.</p></li><li><p><codeclass="inline">:locale</code> is any locale returned by
<ul><li><p>A number of the requested or default type or</p></li><li><p><codeclass="inline">{:error, {exception, error}}</code> if no number could be determined</p></li></ul><h2id="parse/2-notes"class="section-heading">
</span><spanclass="s">"The string </span><spanclass="se">\"</span><spanclass="s">+1.000,34</span><spanclass="se">\"</span><spanclass="s"> could not be parsed as a number"</span><spanclass="p"data-group-id="3219431506-9">}</span><spanclass="p"data-group-id="3219431506-8">}</span></code></pre>
<ul><li><p><codeclass="inline">list</code> is any list in which currency
names and symbols are expected</p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="resolve_currencies/2-options"class="section-heading">
<ul><li><p><codeclass="inline">:locale</code> is any valid locale returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><codeclass="inline">Cldr.LanguageTag</code></a> struct returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><codeclass="inline">Cldr.Locale.new!/2</code></a>
The default is <codeclass="inline">Plausible.Cldr.get_locale()</code></p></li><li><p><codeclass="inline">:only</code> is an <codeclass="inline">atom</code> or list of <codeclass="inline">atoms</code> representing the
currencies or currency types to be considered for a match.
The equates to a list of acceptable currencies for parsing.
See the notes below for currency types.</p></li><li><p><codeclass="inline">:except</code> is an <codeclass="inline">atom</code> or list of <codeclass="inline">atoms</code> representing the
currencies or currency types to be not considered for a match.
This equates to a list of unacceptable currencies for parsing.
See the notes below for currency types.</p></li><li><p><codeclass="inline">:fuzzy</code> is a float greater than <codeclass="inline">0.0</code> and less than or
equal to <codeclass="inline">1.0</code> which is used as input to
<ahref="https://hexdocs.pm/elixir/String.html#jaro_distance/2"><codeclass="inline">String.jaro_distance/2</code></a> to determine is the provided
currency string is <em>close enough</em> to a known currency
string for it to identify definitively a currency code.
It is recommended to use numbers greater than <codeclass="inline">0.8</code> in
order to reduce false positives.</p></li></ul><h2id="resolve_currencies/2-notes"class="section-heading">
<p>The <codeclass="inline">:only</code> and <codeclass="inline">:except</code> options accept a list of
currency codes and/or currency types. The following
types are recognised.</p><p>If both <codeclass="inline">:only</code> and <codeclass="inline">:except</code> are specified,
the <codeclass="inline">:except</code> entries take priority - that means
any entries in <codeclass="inline">:except</code> are removed from the <codeclass="inline">:only</code>
entries.</p><ul><li><p><codeclass="inline">:all</code>, the default, considers all currencies</p></li><li><p><codeclass="inline">:current</code> considers those currencies that have a <codeclass="inline">:to</code>
date of nil and which also is a known ISO4217 currency</p></li><li><p><codeclass="inline">:historic</code> is the opposite of <codeclass="inline">:current</code></p></li><li><p><codeclass="inline">:tender</code> considers currencies that are legal tender</p></li><li><p><codeclass="inline">:unannotated</code> considers currencies that don't have
"(some string)" in their names. These are usually
<pre><codeclass="makeup elixir"translate="no"><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">scan</span><spanclass="p"data-group-id="9313667484-1">(</span><spanclass="s">"100 US dollars"</span><spanclass="p"data-group-id="9313667484-1">)</span><spanclass="w">
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">scan</span><spanclass="p"data-group-id="9313667484-6">(</span><spanclass="s">"100 dollars des États-Unis"</span><spanclass="p"data-group-id="9313667484-6">)</span><spanclass="w">
<ul><li><p><codeclass="inline">list</code> is any list in which currency
names and symbols are expected</p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="resolve_currency/2-options"class="section-heading">
<ul><li><p><codeclass="inline">:locale</code> is any valid locale returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><codeclass="inline">Cldr.LanguageTag</code></a> struct returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><codeclass="inline">Cldr.Locale.new!/2</code></a>
The default is <codeclass="inline">Plausible.Cldr.get_locale()</code></p></li><li><p><codeclass="inline">:only</code> is an <codeclass="inline">atom</code> or list of <codeclass="inline">atoms</code> representing the
currencies or currency types to be considered for a match.
The equates to a list of acceptable currencies for parsing.
See the notes below for currency types.</p></li><li><p><codeclass="inline">:except</code> is an <codeclass="inline">atom</code> or list of <codeclass="inline">atoms</code> representing the
currencies or currency types to be not considered for a match.
This equates to a list of unacceptable currencies for parsing.
See the notes below for currency types.</p></li><li><p><codeclass="inline">:fuzzy</code> is a float greater than <codeclass="inline">0.0</code> and less than or
equal to <codeclass="inline">1.0</code> which is used as input to
<ahref="https://hexdocs.pm/elixir/String.html#jaro_distance/2"><codeclass="inline">String.jaro_distance/2</code></a> to determine is the provided
currency string is <em>close enough</em> to a known currency
string for it to identify definitively a currency code.
It is recommended to use numbers greater than <codeclass="inline">0.8</code> in
order to reduce false positives.</p></li></ul><h2id="resolve_currency/2-returns"class="section-heading">
<ul><li><p>An ISO4217 currency code as an atom or</p></li><li><p><codeclass="inline">{:error, {exception, message}}</code></p></li></ul><h2id="resolve_currency/2-notes"class="section-heading">
<p>The <codeclass="inline">:only</code> and <codeclass="inline">:except</code> options accept a list of
currency codes and/or currency types. The following
types are recognised.</p><p>If both <codeclass="inline">:only</code> and <codeclass="inline">:except</code> are specified,
the <codeclass="inline">:except</code> entries take priority - that means
any entries in <codeclass="inline">:except</code> are removed from the <codeclass="inline">:only</code>
entries.</p><ul><li><p><codeclass="inline">:all</code>, the default, considers all currencies</p></li><li><p><codeclass="inline">:current</code> considers those currencies that have a <codeclass="inline">:to</code>
date of nil and which also is a known ISO4217 currency</p></li><li><p><codeclass="inline">:historic</code> is the opposite of <codeclass="inline">:current</code></p></li><li><p><codeclass="inline">:tender</code> considers currencies that are legal tender</p></li><li><p><codeclass="inline">:unannotated</code> considers currencies that don't have
"(some string)" in their names. These are usually
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">resolve_currency</span><spanclass="p"data-group-id="2273787043-5">(</span><spanclass="s">"dollars des États-Unis"</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">locale</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s">"fr"</span><spanclass="p"data-group-id="2273787043-5">)</span><spanclass="w">
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">resolve_currency</span><spanclass="p"data-group-id="2273787043-7">(</span><spanclass="s">"not a known currency"</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">locale</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s">"fr"</span><spanclass="p"data-group-id="2273787043-7">)</span><spanclass="w">
</span><spanclass="s">"The currency </span><spanclass="se">\"</span><spanclass="s">not a known currency</span><spanclass="se">\"</span><spanclass="s"> is unknown or not supported"</span><spanclass="p"data-group-id="2273787043-9">}</span><spanclass="p"data-group-id="2273787043-8">}</span></code></pre>
<ul><li><p><codeclass="inline">list</code> is any list in which percent
and permille symbols are expected</p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="resolve_per/2-options"class="section-heading">
<ul><li><codeclass="inline">:locale</code> is any valid locale returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><codeclass="inline">Cldr.LanguageTag</code></a> struct returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><codeclass="inline">Cldr.Locale.new!/2</code></a>
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">resolve_per</span><spanclass="w"></span><spanclass="s">"% of linguists"</span><spanclass="w">
</span><spanclass="p"data-group-id="2088667356-2">[</span><spanclass="ss">:percent</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">" of linguists"</span><spanclass="p"data-group-id="2088667356-2">]</span><spanclass="w">
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">resolve_per</span><spanclass="w"></span><spanclass="s">"% of linguists %"</span><spanclass="w">
</span><spanclass="p"data-group-id="2088667356-3">[</span><spanclass="ss">:percent</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">" of linguists "</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">:percent</span><spanclass="p"data-group-id="2088667356-3">]</span></code></pre>
<ul><li><p><codeclass="inline">list</code> is any list in which percent and
permille symbols are expected</p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="resolve_pers/2-options"class="section-heading">
<ul><li><codeclass="inline">:locale</code> is any valid locale returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <codeclass="inline">t:Cldr.LanguageTag</code> struct returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><codeclass="inline">Cldr.Locale.new!/2</code></a>
<ul><li><p><codeclass="inline">string</code> is any <codeclass="inline">String.t</code></p></li><li><p><codeclass="inline">options</code> is a keyword list of options</p></li></ul><h2id="scan/2-options"class="section-heading">
an <codeclass="inline">integer</code> or a <codeclass="inline">float</code>.</p></li><li><p><codeclass="inline">:locale</code> is any locale returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <codeclass="inline">Cldr.LanguageTag.t</code>. The default is <ahref="Plausible.Cldr.html#get_locale/0"><codeclass="inline">Plausible.Cldr.get_locale/0</code></a>.</p></li></ul><h2id="scan/2-returns"class="section-heading">
<p>Number parsing is performed by <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.Parser.html#parse/2"><codeclass="inline">Cldr.Number.Parser.parse/2</code></a>
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">scan</span><spanclass="p"data-group-id="9443778751-5">(</span><spanclass="s">"The prize is 23"</span><spanclass="p"data-group-id="9443778751-5">)</span><spanclass="w">
</span><spanclass="p"data-group-id="9443778751-6">[</span><spanclass="s">"The prize is "</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">23</span><spanclass="p"data-group-id="9443778751-6">]</span><spanclass="w">
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">scan</span><spanclass="p"data-group-id="9443778751-7">(</span><spanclass="s">"The lottery number is 23 for the next draw"</span><spanclass="p"data-group-id="9443778751-7">)</span><spanclass="w">
</span><spanclass="p"data-group-id="9443778751-8">[</span><spanclass="s">"The lottery number is "</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">23</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">" for the next draw"</span><spanclass="p"data-group-id="9443778751-8">]</span><spanclass="w">
</span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">scan</span><spanclass="p"data-group-id="9443778751-9">(</span><spanclass="s">"The loss is -1.000 euros"</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">locale</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s">"de"</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">number</span><spanclass="p">:</span><spanclass="w"></span><spanclass="ss">:integer</span><spanclass="p"data-group-id="9443778751-9">)</span><spanclass="w">
</span><spanclass="p"data-group-id="9443778751-10">[</span><spanclass="s">"The loss is "</span><spanclass="p">,</span><spanclass="w"></span><spanclass="o">-</span><spanclass="mi">1000</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">" euros"</span><spanclass="p"data-group-id="9443778751-10">]</span></code></pre>
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted.
See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.html#to_string/3"><codeclass="inline">Cldr.Number.to_string/3</code></a> for a description of the available
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted.
See <ahref="#to_string/2"><codeclass="inline">Plausible.Cldr.Number.to_string/2</code></a> for a description of the available
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted.
See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.html#to_string/3"><codeclass="inline">Cldr.Number.to_string/3</code></a> for a description of the available
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted.
See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.html#to_string/3"><codeclass="inline">Cldr.Number.to_string/3</code></a> for a description of the available
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted.</p></li></ul><h2id="to_string/2-options"class="section-heading">
formatted. See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.Format.html"><codeclass="inline">Cldr.Number.Format</code></a> for how format strings can be constructed.
See <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.Format.html#format_styles_for/3"><codeclass="inline">Cldr.Number.Format.format_styles_for/3</code></a> to return available format styles
for a locale. The default <codeclass="inline">format</code> is <codeclass="inline">:standard</code>.</p></li><li><p>If <codeclass="inline">:format</code> is set to <codeclass="inline">:long</code> or <codeclass="inline">:short</code> then the formatting depends on
whether <codeclass="inline">:currency</code> is specified. If not specified then the number is
formatted as <codeclass="inline">:decimal_long</code> or <codeclass="inline">:decimal_short</code>. If <codeclass="inline">:currency</code> is
specified the number is formatted as <codeclass="inline">:currency_long</code> or
<codeclass="inline">:currency_short</code> and <codeclass="inline">:fractional_digits</code> is set to 0 as a default.</p></li><li><p><codeclass="inline">:format</code> may also be a format defined by CLDR's Rules Based Number
Formats (RBNF). Further information is found in the module <ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Rbnf.html"><codeclass="inline">Cldr.Rbnf</code></a>.
The most commonly used formats in this category are to spell out the
number in a the locales language. The applicable formats are <codeclass="inline">:spellout</code>,
<codeclass="inline">:spellout_year</code>, <codeclass="inline">:ordinal</code>. A number can also be formatted as roman
numbers by using the format <codeclass="inline">:roman</code> or <codeclass="inline">:roman_lower</code>.</p></li><li><p><codeclass="inline">currency</code>: is the currency for which the number is formatted. For
available currencies see <ahref="https://hexdocs.pm/ex_cldr_currencies/2.15.0/Cldr.Currency.html#known_currencies/0"><codeclass="inline">Cldr.Currency.known_currencies/0</code></a>. This option
is required if <codeclass="inline">:format</code> is set to <codeclass="inline">:currency</code>. If <codeclass="inline">currency</code> is set
and no <codeclass="inline">:format</code> is set, <codeclass="inline">:format</code> will be set to <codeclass="inline">:currency</code> as well.</p></li><li><p><codeclass="inline">currency_symbol</code>: Allows overriding a currency symbol. The alternatives
are:</p><ul><li><codeclass="inline">:iso</code> the ISO currency code will be used instead of the default
currency symbol.</li><li><codeclass="inline">:narrow</code> uses the narrow symbol defined for the locale. The same
narrow symbol can be defined for more than one currency and therefore this
should be used with care. If no narrow symbol is defined, the standard
symbol is used.</li><li><codeclass="inline">:symbol</code> uses the standard symbol defined in CLDR. A symbol is unique
for each currency and can be safely used.</li><li>"string" uses <codeclass="inline">string</code> as the currency symbol</li><li><codeclass="inline">:standard</code> (the default and recommended) uses the CLDR-defined symbol
based upon the currency format for the locale.</li></ul></li><li><p><codeclass="inline">:cash</code>: a boolean which indicates whether a number being formatted as a
<codeclass="inline">:currency</code> is to be considered a cash value or not. Currencies can be
rounded differently depending on whether <codeclass="inline">:cash</code> is <codeclass="inline">true</code> or <codeclass="inline">false</code>.
*This option is deprecated in favour of <codeclass="inline">currency_digits: :cash</code>.</p></li><li><p><codeclass="inline">:currency_digits</code> indicates which of the rounding and digits should be
used. The options are <codeclass="inline">:accounting</code> which is the default, <codeclass="inline">:cash</code> or
<codeclass="inline">:iso</code></p></li><li><p><codeclass="inline">:rounding_mode</code>: determines how a number is rounded to meet the precision
of the format requested. The available rounding modes are <codeclass="inline">:down</code>,
:half_up, :half_even, :ceiling, :floor, :half_down, :up. The default is
<codeclass="inline">:half_even</code>.</p></li><li><p><codeclass="inline">:number_system</code>: determines which of the number systems for a locale
should be used to define the separators and digits for the formatted
number. If <codeclass="inline">number_system</code> is an <codeclass="inline">atom</code> then <codeclass="inline">number_system</code> is
interpreted as a number system. If the <codeclass="inline">:number_system</code> is
<codeclass="inline">binary</code> then it is interpreted as a number system name. See
<ahref="https://hexdocs.pm/ex_cldr_numbers/2.31.3/Cldr.Number.System.html#number_system_names_for/2"><codeclass="inline">Cldr.Number.System.number_system_names_for/2</code></a>. The default is <codeclass="inline">:default</code>.</p></li><li><p><codeclass="inline">:locale</code>: determines the locale in which the number is formatted. See
<ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/0"><codeclass="inline">Cldr.known_locale_names/0</code></a>. The default is<ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#get_locale/0"><codeclass="inline">Cldr.get_locale/0</code></a> which is the
<ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#put_locale/1"><codeclass="inline">Cldr.put_locale/1</code></a>.</p></li><li><p>If <codeclass="inline">:fractional_digits</code> is set to a positive integer value then the number
will be rounded to that number of digits and displayed accordingly - overriding
settings that would be applied by default. For example, currencies have
fractional digits defined reflecting each currencies minor unit. Setting
<codeclass="inline">:fractional_digits</code> will override that setting.</p></li><li><p>If <codeclass="inline">:maximum_integer_digits</code> is set to a positive integer value then the
number is left truncated before formatting. For example if the number <codeclass="inline">1234</code>
is formatted with the option <codeclass="inline">maximum_integer_digits: 2</code>, the number is
truncated to <codeclass="inline">34</code> and formatted.</p></li><li><p>If <codeclass="inline">:round_nearest</code> is set to a positive integer value then the number
will be rounded to nearest increment of that value - overriding
settings that would be applied by default.</p></li><li><p><codeclass="inline">:minimum_grouping_digits</code> overrides the CLDR definition of minimum grouping
digits. For example in the locale <codeclass="inline">es</code> the number <codeclass="inline">1234</code> is formatted by default
as <codeclass="inline">1345</code> because the locale defines the <codeclass="inline">minimium_grouping_digits</code> as <codeclass="inline">2</code>. If
<codeclass="inline">minimum_grouping_digits: 1</code> is set as an option the number is formatting as
<codeclass="inline">1.345</code>. The <codeclass="inline">:minimum_grouping_digits</code> is added to the grouping defined by
the number format. If the sum of these two digits is greater than the number
of digits in the integer (or fractional) part of the number then no grouping
is performed.</p></li><li><p><codeclass="inline">:wrapper</code> is a 2-arity function that will be called for each number component
with parameters <codeclass="inline">string</code> and <codeclass="inline">tag</code> where <codeclass="inline">tag</code> is one of <codeclass="inline">:number</code>,
<codeclass="inline">:permille</code>, <codeclass="inline">:minus</code> or <codeclass="inline">:plus</code>. The function must return a string. The
function can be used to wrap format elements in HTML or other tags.</p></li></ul><h2id="to_string/2-locale-extensions-affecting-formatting"class="section-heading">
<p>A locale identifier can specify options that affect number formatting.
These options are:</p><ul><li><codeclass="inline">nu</code>: defines the number system to be used if none is specified by the <codeclass="inline">:number_system</code>
option to <ahref="#to_string/2"><codeclass="inline">to_string/2</code></a></li></ul><p>This key is part of the <ahref="https://unicode.org/reports/tr35/#u_Extension">u extension</a> and
that document should be consulted for details on how to construct a locale identifier with these
applied to the symbol than the number. For example:</p><pre><codeclass="makeup elixir"translate="no"><spanclass="gp unselectable">iex></span><spanclass="nc">Cldr.Number</span><spanclass="o">.</span><spanclass="n">to_string</span><spanclass="p"data-group-id="3461796178-1">(</span><spanclass="mi">100</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">format</span><spanclass="p">:</span><spanclass="w"></span><spanclass="ss">:currency</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">currency</span><spanclass="p">:</span><spanclass="w"></span><spanclass="ss">:USD</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">wrapper</span><spanclass="p">:</span><spanclass="w"></span><spanclass="k"data-group-id="3461796178-2">fn</span><spanclass="w">
</span><spanclass="p"data-group-id="3461796178-3">{</span><spanclass="ss">:ok</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"<span class=</span><spanclass="se">\"</span><spanclass="s">symbol</span><spanclass="se">\"</span><spanclass="s">>$</span><span class=</span><spanclass="se">\"</span><spanclass="s">number</span><spanclass="se">\"</span><spanclass="s">>100.00</span>"</span><spanclass="p"data-group-id="3461796178-3">}</span></code></pre><p>It is also possible and recommended to use the <ahref="https://hexdocs.pm/phoenix_html/3.3.1/Phoenix.HTML.Tag.html#content_tag/3"><codeclass="inline">Phoenix.HTML.Tag.content_tag/3</code></a>
</span><spanclass="p"data-group-id="7326715065-6">{</span><spanclass="ss">:ok</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"<span class=</span><spanclass="se">\"</span><spanclass="s">symbol</span><spanclass="se">\"</span><spanclass="s">>$</span><span class=</span><spanclass="se">\"</span><spanclass="s">number</span><spanclass="se">\"</span><spanclass="s">>100.00</span>"</span><spanclass="p"data-group-id="7326715065-6">}</span></code></pre><p>When formatting a number the format is parsed into format elements that might include
</span><spanclass="p"data-group-id="4701890250-12">{</span><spanclass="ss">:ok</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"1,244 US dollars"</span><spanclass="p"data-group-id="4701890250-12">}</span><spanclass="w">
</span><spanclass="p"data-group-id="4701890250-15">{</span><spanclass="ss">:ok</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"one thousand two hundred thirty-four"</span><spanclass="p"data-group-id="4701890250-15">}</span><spanclass="w">
</span><spanclass="p"data-group-id="4701890250-16">{</span><spanclass="ss">:ok</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"one thousand two hundred and thirty-four"</span><spanclass="p"data-group-id="4701890250-16">}</span><spanclass="w">
The two most likely causes of an error return are:</p><ul><li>A format cannot be compiled. In this case the error tuple will look like:</li></ul><pre><codeclass="makeup elixir"translate="no"><spanclass="w"></span><spanclass="gp unselectable">iex></span><spanclass="nc">Plausible.Cldr.Number</span><spanclass="o">.</span><spanclass="n">to_string</span><spanclass="p"data-group-id="4913278987-1">(</span><spanclass="mi">12345</span><spanclass="p">,</span><spanclass="w"></span><spanclass="ss">format</span><spanclass="p">:</span><spanclass="w"></span><spanclass="s">"0#"</span><spanclass="p"data-group-id="4913278987-1">)</span><spanclass="w">
</span><spanclass="s">"Decimal format compiler: syntax error before: </span><spanclass="se">\"</span><spanclass="s">#</span><spanclass="se">\"</span><spanclass="s">"</span><spanclass="p"data-group-id="4913278987-3">}</span><spanclass="p"data-group-id="4913278987-2">}</span></code></pre><ul><li>The format style requested is not defined for the <codeclass="inline">locale</code> and
</span><spanclass="s">"The locale :he with number system :hebr does not define a format :standard"</span><spanclass="p"data-group-id="7750725137-3">}</span><spanclass="p"data-group-id="7750725137-2">}</span></code></pre>
<ul><li><p><codeclass="inline">number</code> is an integer, float or Decimal to be formatted</p></li><li><p><codeclass="inline">options</code> is a keyword list defining how the number is to be formatted. See
<ul><li><p><codeclass="inline">locale</code> is any valid locale name returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_locale_names/1"><codeclass="inline">Cldr.known_locale_names/1</code></a>
or a <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.LanguageTag.html"><codeclass="inline">Cldr.LanguageTag</code></a> struct returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.Locale.html#new!/2"><codeclass="inline">Cldr.Locale.new!/2</code></a></p></li><li><p><codeclass="inline">system_name</code> is any number system name returned by
<ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_number_systems/0"><codeclass="inline">Cldr.known_number_systems/0</code></a> or a number system type
returned by <ahref="https://hexdocs.pm/ex_cldr/2.37.2/Cldr.html#known_number_system_types/0"><codeclass="inline">Cldr.known_number_system_types/0</code></a></p></li></ul><h2id="validate_number_system/2-examples"class="section-heading">
</span><spanclass="p"data-group-id="3583381696-4">{</span><spanclass="nc">Cldr.UnknownNumberSystemError</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"The number system :unknown is unknown"</span><spanclass="p"data-group-id="3583381696-4">}</span><spanclass="p"data-group-id="3583381696-3">}</span><spanclass="w">
</span><spanclass="p"data-group-id="3583381696-5">{</span><spanclass="ss">:error</span><spanclass="p">,</span><spanclass="w"></span><spanclass="p"data-group-id="3583381696-6">{</span><spanclass="nc">Cldr.InvalidLanguageError</span><spanclass="p">,</span><spanclass="w"></span><spanclass="s">"The language </span><spanclass="se">\"</span><spanclass="s">zz</span><spanclass="se">\"</span><spanclass="s"> is invalid"</span><spanclass="p"data-group-id="3583381696-6">}</span><spanclass="p"data-group-id="3583381696-5">}</span></code></pre>