Presentation options
notation
The formatting options for numbers are:
"standard"(default): Plain number formatting."scientific": Displays the order of magnitude."engineering": Displays the exponent in multiples of three."compact": Uses a compact notation (e.g., "short" form by default).
NOTE
This option affects significant and fractional digits option defaults
Examples:
compactDisplay
Only applicable when notation is "compact". Values: "short" (default) or "long".
Examples:
Formatter options used in this example
typescript
{
notation: 'compact';
}useGrouping
Whether to use grouping separators:
"always"- Always display grouping separators."auto"- Display grouping separators based on locale preferences."min2"- Display grouping separators for groups with at least 2 digits.true- Equivalent to"always".false- No grouping separators.
Default: "min2" for "compact" notation, "auto" otherwise.
signDisplay
When to display the sign for the number:
"auto"(default): Display sign for negative numbers, including negative zero."always": Always display the sign."exceptZero": Display sign for non-zero numbers only."negative": Display sign for negative numbers, excluding negative zero."never": Never display the sign.
Examples:
parts
An array of localized value parts to extract. Possible values:
| Value | Description |
|---|---|
"literal" | Static text in the format, e.g., " ". |
"integer" | Whole number part, or segments if grouping is used. |
"group" | Group separator, e.g., ",". Present if grouping is enabled. |
"decimal" | Decimal separator, e.g., ".". Present if a fraction exists. |
"fraction" | Fractional part of the number. |
"compact" | Compact notation, e.g., "M". Requires notation: "compact". |
"exponentSeparator" | Exponent separator, e.g., "E". Requires notation: "scientific" or "engineering". |
"exponentMinusSign" | Exponent minus sign, e.g., "-". Present for negative exponents. |
"exponentInteger" | Exponent value. Requires notation: "scientific" or "engineering". |
"nan" | Represents NaN, e.g., "NaN". |
"infinity" | Represents Infinity, e.g., "∞". |
"plusSign" | Plus sign, e.g., "+". |
"minusSign" | Minus sign, e.g., "-". |
"percentSign" | Percent sign, e.g., "%". Applicable to percentFormatter. |
"unit" | Unit string, e.g., "l". Controlled by unitDisplay. |
"currency" | Currency string, e.g., "$". Controlled by currencyDisplay. |
"unknown" | Unrecognized tokens. Rarely encountered. |
NOTE
This option reflects type fields of the returned value of Intl.NumberFormat.formatToParts()
"Attributions and copyright licensing" by Mozilla Contributors, licensed under CC-BY-SA 4.0.