| Operator Type: | Function |
| Operator Scope of Action: | Item |
| Operator Purpose: | Formatting |
Number.format(decimalsN[,widthN])
New to v5.8.0, returns Number as a string, formatted to decimalsN decimal places.
If widthN is supplied, Number returned additionally left padded with spaces so that places+Number(decimalsN) = widthN.
Note that with widthN, decimal character is not counted as part of the number
For example, if $MyNum is 3.1415927, then
$MyNum.format(2) is 3.14
$MyNum.format(0) is 3
$MyNum.format(2,7), is " 3.14" (3 spaces + number + period + 3 numbers = 7)
Literal numbers, e.g. 3.1415927, can also be worked with:
5.1415927.format(2) is 5.14
The above works but the following syntax may seem less ambiguous by using parentheses to delimit the literal number:
(5.1415927).format(2) is 5.14
(5.1415927).format(1,2) is ' 5.1' (two left padding paces)
Number.format("formatString")
New to v5.10.3, an alternate usage is to supply a quoted formatString. Currently only one such string is supported: "L". This will return a string of the number formatted with (OS) locale-dependent group & decimal delimiters. For example, for the US locale these are a comma and a period; in other locales they may vary.
This function supplements the existing format() and Number.precision() functions.
