Formats a number in a specific way given the format string. Similar to the format() command.
format number (number, the number that gets formatted) format (text, the format string, see below)
# | Placeholder that displays the digit from the value if it is present. If fewer placeholder characters are used than in the passed number, then the result is rounded. |
0 | Placeholder that displays the digit from the value if it is present. If no digit is present, 0 (Zero) is displayed in it’s place. (say you wanted a month that was always zero padded then you’d pass the month number with a format string of “00”) |
. | Placeholder for the position of the decimal point. |
, | Placeholder that indicates the number should be formatted with thousands separators. |
% | displays the number multiplied by 100. |
( | displays an open paren. |
) | displays a closed paren. |
+ | displays the plus sign to the left of the number if the number is positive or the minus sign if negative. |
- | displays the minus sign to the left of the number if the number is negative, makes no change if the number is positive. |
E or e | displays the number in scientific notation. |
\character | displays the character that follows the backslash. |
additionally the string may contain 3 formats separated by semicolons to be used when the number is positive, negative or zero.
Format | Number | Formatted String |
---|---|---|
#.## | 1.786 | 1.79 |
#.0000 | 1.3 | 1.3000 |
0000 | 5 | 0005 |
#% | 0.25 | 25% |
###,###.## | 145678.5 | 145,678.5 |
#.##e | 145678.5 | 1.46e+5 |
-#.## | -3.7 | -3.7 |
+#.## | 3.7 | +3.7 |
#.##;(#.##);/z/e/r/o | 3.7 | 3.7 |
#.##;(#.##);/z/e/r/o | -3.7 | (3.7) |
#.##;(#.##);/z/e/r/o | 0 | zero |