Cldr Numbers v0.3.1 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 Cldr.Locale.new("en")
[: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.

Link to this section Summary

Functions

Formats a number according to a decimal format string

Link to this section Functions

Link to this function to_string(number, format, options) View Source
to_string(Cldr.Math.number(), String.t(), Map.t()) ::
  {:ok, String.t()} |
  {:error, {atom(), String.t()}}

Formats a number according to a decimal format string.

This function is not part of the public API. The public API is Cldr.Number.to_string/2.

  • 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 update_meta(meta, number, options) View Source