Cldr.Number.Formatter.Decimal (Cldr Numbers v2.22.1) View Source

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

Link to this function

absolute_value(number, meta, backend, options)

View Source
Link to this function

add_first_group(groups, first, separator)

View Source
Link to this function

add_last_group(groups, last, separator)

View Source
Link to this function

add_separator(group, every, separator)

View Source
Link to this function

adjust_for_fractional_digits(meta, digits)

View Source
Link to this function

adjust_for_integer_digits(meta, digits)

View Source
Link to this function

adjust_for_round_nearest(meta, digits)

View Source
Link to this function

adjust_fraction_for_currency(meta, currency, arg3, backend)

View Source
Link to this function

adjust_fraction_for_significant_digits(meta, number)

View Source
Link to this function

adjust_leading_zeros(arg, map, backend, options)

View Source
Link to this function

adjust_trailing_zeros(arg, map, backend, options)

View Source
Link to this function

apply_grouping(arg, map1, backend, map2)

View Source
Link to this function

assemble_format(number_string, meta, backend, options)

View Source
Link to this function

currency_symbol(currency, symbol, number, size, locale, backend)

View Source
Link to this function

do_adjust_fraction(meta, digits, rounding)

View Source
Link to this function

do_grouping(number, grouping, length, min_grouping, arg5)

View Source
Link to this function

do_max_integer_digits(integer, over)

View Source
Link to this function

do_trailing_zeros(fraction, count)

View Source
Link to this function

minimum_group_size(map, minimum_grouping_digits, locale, backend)

View Source
Link to this function

multiply_by_factor(number, map, backend, options)

View Source
Link to this function

output_to_tuple(number, meta, backend, options)

View Source
Link to this function

padding_string(meta, number_string)

View Source
Link to this function

reassemble_number_string(arg, meta, backend, options)

View Source
Link to this function

round_fractional_digits(arg, arg2, backend, arg4)

View Source
Link to this function

round_to_nearest(number, map1, backend, map2)

View Source
Link to this function

round_to_significant_digits(number, map, backend, options)

View Source
Link to this function

set_exponent(number, meta, backend, options)

View Source
Link to this function

set_max_integer_digits(number, map, backend, options)

View Source
Link to this function

to_string(number, format, backend, options \\ [])

View Source

Specs

to_string(Cldr.Math.number_or_decimal(), String.t(), Cldr.backend(), list()) ::
  {:ok, String.t()} | {:error, {module(), String.t()}}
to_string(
  Cldr.Math.number_or_decimal(),
  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

  • number is an integer, float or Decimal

  • format is a format string. See Cldr.Number for further information.

  • backend is any module that includes use Cldr and therefore is a Cldr backend module

  • options is a map of options. See Cldr.Number.to_string/2 for further information.

Link to this function

transliterate(number_string, meta, backend, map)

View Source