You format monetary values using a combination of the pSepBySpace, pSignPosn, pCsPrecedes, nSepBySpace, nSignPosn, and nCsPrecedes values. The first three values are used when formatting positive values, and the last three when formatting negative values. Together these variables control the relative positions of the currency symbol and sign indicator. Instances of the LCMonetary class are used to hold these parameters for a particular locale.
The following table illustrates the use of these parameters in formatting the non-negative monetary value 1.25. The same formatting rules are also used to format negative monetary values by changing the positive sign character to a negative sign character.
The pCsPrecedes value indicates the relative position of the currency symbol in formatted monetary qualities.
The SepBySpace value indicates if the currency symbol is separated from the monetary quantity by a space in formatted monetary quantities.
The pSignPosn value specifies the relative position of the positive sign string formatted monetary quantities.
Table 47. Numeric formats specified by currency symbol, spacing, and sign location
| pSepBySpace | |||
2 | 1 | 0 | ||
psCsPrecedes = 0 | pSignPosn = 0 | (1.25 $) | (1.25$) | (1.25$) |
pSignPosn = 1 | +1.25 $ | +1.25 $ | +1.25 $ | |
pSignPosn = 2 | 1.25$ + | 1.25$ + | 1.25$ + | |
pSignPosn = 3 | 1.25 +$ | 1.25 +$ | 1.25 +$ | |
pSignPosn = 4 | 1.25 $+ | 1.25 $+ | 1.25 $+ | |
pCsPrecedes = 1 | psignPosn = 0 | ($1.25) | ($1.25) | ($1.25) |
pSignPosn = 1 | + $1.25 | + $1.25 | + $1.25 | |
pSignPosn = 2 | $1.25 + | $1.25 + | $1.25 + | |
pSignPosn = 3 | + $1.25 | + $1.25 | + $1.25 | |
pSignPosn = 4 | $+ 1.25 | $+ 1.25 | $+ 1.25 |
A grouping string is used to specify the size of each group of digits in formatted monetary and numeric quantities. The grouping string consists of a series of numbers separated by spaces. The first number in the string indicates the size of the group of digits immediately to the left of the decimal indicator.
The following numbers have special meaning in the grouping string:
The effects of the grouping string on monetary formatting are most easily
visualized by example. The following table illustrates formatting the
number 123456789 as a function of the grouping string, using a comma as the
separator.
Table 48. Use of the grouping string to format numeric values
Grouping string | Resultant formatted numeric quantity |
---|---|
'3' | 123456,789 |
'3 0' | 123,456,789 |
'3 2' | 1234,56,789 |
'3 2 127' | 1234,56,789 |
'3 2 0' | 12,34,56,789 |
'127' | 123456789 |
'' | 123456789 |