The numeric value to format.
Configuration object.
Optional
decimals?: numberDefault 0
. Number of decimal places to include.
Optional
decimalSeparator?: stringDefault '.'
. Character to use as the decimal separator.
Optional
significativeNumber?: booleanDefault false
. If true
, trailing zeros in the decimal part will be omitted.
Optional
thousandSeparator?: stringDefault ','
. Character to use as the thousand separator.
A formatted string representing the number.
console.log(PUtilsNumber.format(123456789.1234)) // 123,456,789
console.log(PUtilsNumber.format(123456789.1234, { decimals: 2 })) // 123,456,789.12
console.log(PUtilsNumber.format(123456789.1234, { decimals: 5 })) // 123,456,789.12340
console.log(PUtilsNumber.format(123456789.1234, { decimals: 5, significativeNumber: true })) // 123,456,789.1234
console.log(PUtilsNumber.format(123456789.1234, { decimals: 5, significativeNumber: true, decimalSeparator: ',', millarSeparator: ' ' })) // 123 456 789,1234
Converts a number to a formatted string representation.