-
Notifications
You must be signed in to change notification settings - Fork 4
Function.formatNumber
connor-baer edited this page Aug 14, 2024
·
45 revisions
@sumup/intl / formatNumber
formatNumber(
value
,locales
?,options
?):string
Formats a number with support for various styles, units, and notations.
Parameter | Type |
---|---|
value |
number |
locales ? |
string | string [] |
options ? |
NumberFormatOptions |
string
import { formatNumber } from '@sumup/intl';
formatNumber(12345.67, 'de-DE'); // '12.345,67'
formatNumber(-0.89, ['ban', 'id']); // '-0,89'
formatNumber(16, 'en-GB', {
style: 'unit',
unit: 'liter',
unitDisplay: 'long',
}); // 16 litres
In runtimes that don't support the Intl.NumberFormat
API, the number is
formatted using the Number.toLocaleString
API.