Format number

This function takes a number as a parameter and formats it as a number string based on the specified options.

See reference of the underlying implementation here.

Parameters

  • style (string, required): how to display the number, available values decimal, percent, unit
  • unit (string, optional): the unit to display next to the number
  • locale (string, optional): the locale used to display the number
  • minDecimal (number, optional): the minimum number of decimal places to include in the formatted currency string. If not provided, the default minimum of 2 decimal places will be used.
  • maxDecimal (number, optional): the maximum number of decimal places to include in the formatted currency string. If not provided, the default maximum of 2 decimal places will be used.

Examples

format-number(123456.789, style="decimal", locale="en-US")
# returns "1233,456.79"