
180
LESSON 14 Working With StringS
For the C, E, F, N, and P formats, the precision specifier indicates the number of digits after the
decimal point.
Custom Numeric Formats
If the standard numeric formatting characters don’t do what you want, you can use a custom
numeric format. Table 14-3 summarizes the custom numeric formatting characters.
TABLE 143
CHARACTER MEANING
0 Digit or zero. A digit is displayed here or a zero if there is no corresponding digit in
the value being formatted.
# Digit or nothing. A digit is displayed here or nothing if there is no corresponding
digit in the value being formatted.
. Decimal separator. The decimal separator goes here. Note that the actual separa-
tor character may not be a period depending on the computer’s regional settings,
although you still use the period in the format string.
, Thousands separator. The thousands separator goes here. The actual separator
character may not be a comma depending on the computer’s regional settings,
although you still use the comma in the format string.
% Percent. The number is multiplied by 100 and the percent sign is added at this point.
For example, %0 puts the percent sign before the number and 0% puts it after.
E+0 Scientific notation. The number of 0s indicates the number of digits in the exponent.
If + is included, the exponent always includes a + or – sign. If + is omitted, the expo-
nent only includes a sign ...