Standard Numeric Format Strings

CharacterDescription
AStandard format string takes the form Axx where A is a single alphabetic character called the format specifier, and xx is an optional integer called the precision specifier (e.g.: D4, C2).
C,cCurrency. The number is converted to a string that represents a currency amount. The precision specifier indicates the desired number of decimal places.
D,dDecimal. This format is supported for integral types only. The number is converted to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier.
F,fFixed Point. The number is converted to a string of the form "-ddd.ddd" where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. The precision specifier indicates the desired number of decimal places.
N,nNumber. The number is converted to a string of the form "-d,ddd,ddd.ddd􁪽", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. Thousand separators are inserted between each group of three digits to the left of the decimal point. The precision specifier indicates the desired number of decimal places.
P,pPercent. The number is converted to a string that represents a percent. The converted number is multiplied by 100 in order to be presented as a percentage. The precision specifier indicates the desired number of decimal places.

On this page:

Related Pages: