Numeric formatting symbols

The following table lists the symbols you can use to specify a numeric format.

Table 1. Numeric formatting symbols
Symbol Meaning
# A digit that uses a space as the fill character for a leading zero (unless the < character is also present).
* A digit that uses an asterisk (*) as the fill character for a leading zero (unless the < character is also present).
& A digit that uses a zero as the fill character for a leading zero (unless the < character is also present).
< Left justify the number. Leading zeros are not represented in the output.
, Use a locale-dependent numeric separator unless the position contains a leading zero.
. Use a locale-dependent decimal point.
- Use a minus sign (-) for values less than 0; use a space for values greater than or equal to 0.
+ Use a minus sign for values less than 0; use a plus sign (+) for values greater than or equal to 0.
(...) Enclose negative values with parentheses. The positions of the parentheses in the format string determine their positions in the result.
$ Precede the value with the locale-dependent currency symbol. This symbol is useful only when you place it at the beginning of the pattern.
@ Place the locale-dependent currency symbol after the value.

Examples

In the table below, the letter "b" represents a blank space.

Table 2.
Format String Data Value Formatted Result Comments
"#####" 0 bbbbb No zero symbol
"&&&&&" 0 00000  
"$$$$$" 0 bbbb$ No zero symbol
"*****" 0 ***** No zero symbol
"<<<<<" 0   (empty string)
"<<<,<<<" 12345 12,345  
"<<<,<<<" 1234 1,234  
"<<<,<<<" 123 123  
"<<<,<<<" 12 12  
"##,###" 12345 12,345  
"##,###" 1234 b1,234  
"##,###" 123 bbb123  
"##,###" 12 bbbb12  
"##,###" 1 bbbbb1  
"##,###" -1 bbbbb1 No negative sign
"&&,&&&" 12345 12,345  
"&&,&&&" 1234 01,234  
"&&,&&&" 123 000123  
"&&,&&&" 12 000012  
"&&,&&&" 1 000001  
"&&,&&&" -1 000001 No negative sign
"&&,&&&" 0 000000  
"&&,&&&.&&" 12345.67 12,345.67  
"&&,&&&.&&" 1234.56 01,234.56  
"&&,&&&.&&" 123.45 000123.45  
"&&,&&&.&&" 0.01 000000.01  
"$$,$$$" 12345 ****** Overflow
"$$,$$$" 1234 $1,234  
"$$,$$$" 123 bb$123  
"$$,$$$" 12 bbb$12  
"$$,$$$" 1 bbbb$1  
"$$,$$$" 0 bbbbb$ No zero symbol

Feedback