Digit options
minimumIntegerDigits
The minimum number of integer digits to use. Values with fewer digits are left-padded with zeros to meet the specified length. Valid range: 1 to 21 (default: 1).
Examples:
minimumFractionDigits
The minimum number of fraction digits to display. Valid range: 0 to 100. Defaults: 0 for plain numbers and percentages, or 2 for currencies (based on ISO 4217). See significant and fraction digits default values for details.
Examples:
maximumFractionDigits
The maximum number of fraction digits to use. Valid range: 0 to 100. Defaults:
- Plain numbers: The larger of
minimumFractionDigitsor3. - Currencies: The larger of
minimumFractionDigitsor the minor unit digits from the ISO 4217 currency code list (2if unspecified). - Percentages: The larger of
minimumFractionDigitsor0.
See significant and fraction digits default values for details.
Examples:
minimumSignificantDigits
The minimum number of significant digits to use. Possible values are from 1 to 21; the default is 1. See significant and fraction digits default values default values for when this default gets applied.
Examples:
maximumSignificantDigits
The maximum number of significant digits to use. Valid range: 1 to 21 (default: 21). See significant and fraction digits default values for details.
Examples:
roundingPriority
Specify how rounding conflicts are resolved when both fraction digits options (minimumFractionDigits/maximumFractionDigits) and significant digits options (minimumSignificantDigits/maximumSignificantDigits) are set:
"auto"(default) - Uses the result from significant digits."morePrecision"- Chooses the property yielding more precision."lessPrecision"- Chooses the property yielding less precision.
If notation is "compact" and none of these options are set, "auto" is normalized to "morePrecision".
NOTE
With values other than auto, the result is determined by maximumSignificantDigits and maximumFractionDigits, ignoring minimum digit settings. See default values for details.
Examples:
Formatter options used in this example
{
minimumSignificantDigits: 3;
maximumSignificantDigits: 6;
minimumFractionDigits: 3;
}roundingIncrement
Defines the step size for rounding, based on the calculated rounding magnitude. Supported values include 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, and 5000. The default is 1. This option is incompatible with significant-digits rounding or any roundingPriority setting other than "auto".
WARNING
This option requires maximumFractionDigits set to 0.
Examples:
Formatter options used in this example
{
minimumFractionDigits: 0;
}roundingMode
How decimals are rounded. Possible values:
| Rounding mode | Description |
|---|---|
"ceil" | Round up (toward +∞). |
"floor" | Round down (toward -∞). |
"expand" | Round away from 0. |
"trunc" | Round toward 0. |
"halfCeil" | Ties round up (toward +∞). |
"halfFloor" | Ties round down (toward -∞). |
"halfExpand" | Ties round away from 0 (default). |
"halfTrunc" | Ties round toward 0. |
"halfEven" | Ties round to the nearest even number. |
Examples:
Formatter options used in this example
{
maximumSignificantDigits: 1;
}trailingZeroDisplay
The strategy for displaying trailing zeros on whole numbers:
"auto"(default): Retains trailing zeros based onminimumFractionDigitsandminimumSignificantDigits."stripIfInteger": Removes fraction digits if all are zero; behaves like"auto"if any fraction digit is non-zero.
Examples:
Formatter options used in this example
{
minimumFractionDigits: 2;
}Significant and fraction digits default values
For the four options above, defaults are applied only when the property is used, based on roundingPriority and notation:
- If
roundingPriorityis not"auto", all four options apply. - If
roundingPriorityis"auto"and a significant digits option is set, only significant digits options apply. - If
roundingPriorityis"auto"and a fraction digits option is set ornotationis not"compact", only fraction digits options apply. - If
roundingPriorityis"auto",notationis"compact", and none of the four options are set, they default to{ minimumFractionDigits: 0, maximumFractionDigits: 0, minimumSignificantDigits: 1, maximumSignificantDigits: 2 }withroundingPriorityset to"morePrecision".
"Attributions and copyright licensing" by Mozilla Contributors, licensed under CC-BY-SA 4.0.