num | String The number to format. | |
pattern | String A pattern string that describes the way in which num is to be formatted: | |
This symbol... | Indicates... | |
0 | A digit. | |
# | A digit. Leading zeroes will not be shown. | |
. | A placeholder for a decimal separator. | |
, | A placeholder for a grouping separator. | |
; | A separation in format. | |
- | The default negative prefix. | |
% | That num will be multiplied by 100 and shown as a percentage. | |
X | Any character used as a prefix or suffix (for example, A, $). | |
' | That special characters are to be used as literals in a prefix or suffix. Enclose the special characters within '' (for example, '#'). | |
The following are examples of pattern strings: | ||
Pattern | Description | |
#,### | Use commas to separate into groups of three digits. The pound sign denotes a digit and the comma is a placeholder for the grouping separator. | |
#,#### | Use commas to separate into groups of four digits. | |
$#.00 | Show digits before the decimal point as needed and exactly two digits after the decimal point. Prefix with the $ character. | |
'#'#.0 | Show digits before the decimal point as needed and exactly one digit after the decimal point. Prefix with the # character. The first character in a pattern is the dollar sign ($). The pound sign denotes a digit and the period is a placeholder for decimal separator. |
value | Stringnum formatted according to pattern. If pattern is an empty (not null) string, the default pattern of comma separators is used and the number of digits after the decimal point remains unchanged. |