View Source Cldr.Number.Formatter.Decimal (Cldr Numbers v2.27.2)
Formats a number according to a locale-specific predefined format or a user-defined format.
As a performance optimization, all decimal formats known at compile time are compiled into function that roughly halves the time to format a number compared to a non-precompiled format.
The available format styles for a locale can be returned by:
iex> Cldr.Number.Format.decimal_format_styles_for("en", :latn, TestBackend.Cldr)
{:ok, [:accounting, :currency, :currency_long, :percent, :scientific, :standard]}
This allows a number to be formatted in a locale-specific way but using a standard method of describing the purpose of the format.
This module is not part of the public API and is subject to change at any time.
Link to this section Summary
Functions
Formats a number according to a decimal format string.
Link to this section Functions
@spec to_string( Cldr.Math.number_or_decimal() | String.t(), String.t(), Cldr.backend(), list() ) :: {:ok, String.t()} | {:error, {module(), String.t()}}
@spec to_string( Cldr.Math.number_or_decimal() | String.t(), String.t(), Cldr.backend(), Cldr.Number.Format.Options.t() ) :: {:ok, String.t()} | {:error, {atom(), String.t()}}
Formats a number according to a decimal format string.
arguments
Arguments
number
is an integer, float or Decimalformat
is a format string. SeeCldr.Number
for further information.backend
is any module that includesuse Cldr
and therefore is aCldr
backend moduleoptions
is a map of options. SeeCldr.Number.to_string/2
for further information.