Cldr Numbers v2.1.0 Cldr.Number.Formatter.Decimal 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

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_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, number, size, locale, backend) View Source
Link to this function do_adjust_fraction(meta, digits, rounding) View Source
Link to this function do_assemble_format(number_string, number, meta, format, backend, options) View Source
Link to this function do_grouping(number, arg2, 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
to_string(Cldr.Math.number(), String.t(), CLdr.backend(), Map.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.

  • 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