Table of Contents

Format Number

Formats a number in a specific way given the format string. Similar to the format() command.

Usage:

format number (number, the number that gets formatted) format (text, the format string, see below)

format string spec:

# 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.

Examples:

FormatNumberFormatted String
#.##1.7861.79
#.00001.31.3000
000050005
#%0.2525%
###,###.##145678.5145,678.5
#.##e145678.51.46e+5
-#.##-3.7-3.7
+#.##3.7+3.7
#.##;(#.##);/z/e/r/o3.73.7
#.##;(#.##);/z/e/r/o-3.7(3.7)
#.##;(#.##);/z/e/r/o0zero