# new NumFmt(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object.<string, *>
|
A set of options that govern how the formatter will behave |
Methods
# constrain(num) → {number}
Apply the constraints used in the current formatter to the given number. This will will apply the maxFractionDigits, significantDigits, and rounding mode constraints and return the result. The result is further manipulated in the format method to produce the final formatted number string. This method is intended for use by code that needs to use the same number that this formatter instance uses for formatting before that number is turned into a formatted string.
Parameters:
Name | Type | Description |
---|---|---|
num |
number
|
the number to constrain |
the number with the constraints applied to it
number
# format(num) → {string}
Format a number according to the settings of this number formatter instance.
Parameters:
Name | Type | Description |
---|---|---|
num |
number
|
string
|
INumber
|
Number
|
a floating point number to format |
a string containing the formatted number
string
# getCurrency() → {string}
Returns the ISO 4217 code for the currency that this formatter formats. IF the typeof this formatter is not "currency", then this method will return undefined.
the ISO 4217 code for the currency that this formatter formats, or undefined if this not a currency formatter
string
# getLocale() → {Locale}
Return the locale for this formatter instance.
the locale instance for this formatter
# getMaxFractionDigits() → {number}
Returns the maximum fraction digits set up in the constructor.
the maximum number of fractional digits this formatter will format, or -1 for no maximum
number
# getMinFractionDigits() → {number}
Returns the minimum fraction digits set up in the constructor. If the formatter has the type "currency", then the minimum fraction digits is the amount of digits that is standard for the currency in question unless overridden in the options to the constructor.
the minimum number of fractional digits this formatter will format, or -1 for no minimum
number
# getRoundingMode() → {string}
Returns the rounding mode set up in the constructor. The rounding mode controls how numbers are rounded when the integral or fraction digits of a number are limited.
the name of the rounding mode used in this formatter
string
# getSignificantDigits() → {number}
Returns the significant digits set up in the constructor.
the number of significant digits this formatter will format, or -1 for no minimum
number
# getStyle() → {string}
If this formatter is a currency formatter, then the style determines how the currency is denoted in the formatted output. This method returns the style that this formatter will produce. (See the constructor comment for more about the styles.)
the name of the style this formatter will use to format currency amounts, or "undefined" if this formatter is not a currency formatter
string
# getType() → {string}
Return the type of formatter. Valid values are "number", "currency", and "percentage".
the type of formatter
string
# getUseNative() → {boolean}
Return true if this formatter uses native digits to format the number. If the useNative option is given to the constructor, then this flag will be honoured. If the useNative option is not given to the constructor, this this formatter will use native digits if the locale typically uses native digits.
true if this formatter will format with native digits, false otherwise
boolean
# isGroupingUsed() → {boolean}
Returns true if this formatter groups together digits in the integral portion of a number, based on the options set up in the constructor. In most western European cultures, this means separating every 3 digits of the integral portion of a number with a particular character.
true if this formatter groups digits in the integral portion of the number
boolean