DecimalFormatStyleType
Indicates which format style to use when formatting decimal numbers.
'decimal' | 'short' | 'long' | 'percent' | 'percent-scaled' | 'permille' | 'permille-scaled' | 'scientific'
Values
"decimal"
- Default formatting.
"short"
- Compact form, using as few digits as needed, with a short indicator of the order of magnitude.
"long"
- Compact form, using as few digits as needed, with a long indicator of the order of magnitude.
"percent"
- Formats a number as a percent, first multiplying it by 100.
"percent-scaled"
- formats a number as a percent, without multiplying.
"permille"
- Formats a number as a permille, first multiplying it by 1000.
"permille-scaled"
- Formats a number as a permille, without multiplying.
"scientific"
- Formats a number in scientific notation (beta)
Example
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('123456.6789', { style: 'decimal' }));
123,456.679
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('123456.6789', { style: 'decimal', group: false }));
123456.679
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('123456.6789', { style: 'short' }));
123K
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('123456.6789', { style: 'long' }));
123 thousand
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('12.3456', { style: 'percent' }));
1,235%
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('12.3456', { style: 'percent-scaled' }));
12%
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('12.3456', { style: 'permille' }));
12,346‰
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('12.3456', { style: 'permille-scaled' }));
12‰
const cldr = framework.get('en');
log(cldr.Numbers.formatDecimal('1234.56789', { style: 'scientific', minimumSignificantDigits: 4 }));
log(cldr.Numbers.formatDecimal('0.0000098765', { style: 'scientific', minimumSignificantDigits: 4 }));
1.235E+3 9.876E-6