Class jsworld.NumericFormatter
Class for localised formatting of numbers.
See:
POSIX LC_NUMERIC.
Defined in: <JsWorld.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
jsworld.NumericFormatter(locale)
Creates a new numeric formatter for the specified locale.
|
Method Attributes | Method Name and Description |
---|---|
format(number, options)
Formats a decimal numeric value according to the preset
locale.
|
Class Detail
jsworld.NumericFormatter(locale)
Creates a new numeric formatter for the specified locale.
- Parameters:
- {jsworld.Locale} locale
- A locale object specifying the required POSIX LC_NUMERIC formatting properties.
- Throws:
- Error on constructor failure.
Method Detail
{String}
format(number, options)
Formats a decimal numeric value according to the preset
locale.
- Parameters:
- {Number|String} number
- The number to format.
- {String} options Optional
- Options to modify the formatted output:
- "^" suppress grouping
- "+" force positive sign for positive amounts
- "~" suppress positive/negative sign
- ".n" specify decimal precision 'n'
- Throws:
- "Error: Invalid input" on bad input.
- Returns:
- {String} The formatted number.