Methods
asDecimal(number, localeopt, minPrecisionopt, nullable, maxPrecisionopt, nullable) → {String}
Renders a number as a decimal value, using native Intl.NumberFormat functionality.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
number |
Number | the number to use as a decimal amount |
||
locale |
String | Array.<String> |
<optional> |
'en-US' | locale to use, use array to define fallback; always falls back to en-US if nothing else works |
minPrecision |
Number |
<optional> <nullable> |
2 | the minimal precision to use in decimal display |
maxPrecision |
Number |
<optional> <nullable> |
null | the minimal precision to use in decimal display; if nullish, will be set to minPrecision |
- Source:
- See:
Returns:
the formatted decimal amount
- Type
- String
Example
asDecimal(42.666)
=> '42.67'
asDecimal(42.666, 'de-DE', 1)
=> '42,7'