localized formatting and parsing routines for Number
See the dojo/number reference documentation for more information.
Apply pattern to format value as a string using options. Gives no consideration to local customs.
Parameter | Type | Description |
---|---|---|
value | Number | the number to be formatted. |
pattern | String | a pattern string as described by unicode.org TR35 |
options | Object |
Optional _applyPattern is usually called via |
Apply numeric pattern to absolute value using options. Gives no consideration to local customs.
Parameter | Type | Description |
---|---|---|
value | Number | the number to be formatted, ignores sign |
pattern | String | the number portion of a pattern (e.g. |
options | Object |
Optional An object with the following properties:
|
Builds a regular expression that matches an integer
Parameter | Type | Description |
---|---|---|
flags | Object |
Optional An object with the following properties:
|
Parameter | Type | Description |
---|---|---|
options | Object |
Optional
|
Builds a regular expression to match a real number in exponential notation
Parameter | Type | Description |
---|---|---|
flags | __RealNumberRegexpFlags |
Optional
|
Format a Number as a String, using locale-specific settings
Create a string from a Number using a known localized pattern. Formatting patterns appropriate to the locale are chosen from the Common Locale Data Repository as well as the appropriate symbols and delimiters. If value is Infinity, -Infinity, or is not a valid JavaScript number, return null.
Parameter | Type | Description |
---|---|---|
value | Number | the number to be formatted |
options | Object |
Optional An object with the following properties:
|
Convert a properly formatted string to a primitive Number, using locale-specific settings.
Create a Number from a string using a known localized pattern. Formatting patterns are chosen appropriate to the locale and follow the syntax described by unicode.org TR35 Note that literal characters in patterns are not supported.
Parameter | Type | Description |
---|---|---|
expression | String | A string representation of a Number |
options | Object |
Optional An object with the following properties:
|
Builds the regular needed to parse a number
Returns regular expression with positive and negative match, group and decimal separators
Parameter | Type | Description |
---|---|---|
options | Object |
Optional An object with the following properties:
|
Rounds to the nearest value with the given number of decimal places, away from zero
Rounds to the nearest value with the given number of decimal places, away from zero if equal. Similar to Number.toFixed(), but compensates for browser quirks. Rounding can be done by fractional increments also, such as the nearest quarter. NOTE: Subject to floating point errors. See dojox/math/round for experimental workaround.
Parameter | Type | Description |
---|---|---|
value | Number | The number to round |
places | Number |
Optional The number of decimal places where rounding takes place. Defaults to 0 for whole rounding. Must be non-negative. |
increment | Number |
Optional Rounds next place to nearest value of increment/10. 10 by default. |
>>> number.round(-0.5) -1 >>> number.round(162.295, 2) 162.29 // note floating point error. Should be 162.3 >>> number.round(10.71, 0, 2.5) 10.75