Compiler Library/XL Reference Manual (32650-90029)

3- 7
Table 3-3. Gw.d Formatting Rules
-------------------------------------------------------------------------------------------
| | |
| Value | Format Used |
| | |
-------------------------------------------------------------------------------------------
| | |
| intlvalue < 0.1 | E
w.d
|
| | |
| 0.1 <= intlvalue < 1 | F(
w
-4).
d
plus 4 spaces |
| | |
| 1 < intlvalue < 101 | F(
w
-4).(
d
-1) plus 4 spaces |
| | |
| 101 <= intlvalue < 102 | F(
w
-4).(
d
-2) plus 4 spaces |
| | |
| 102 <= intlvalue < 103 | F(
w
-4).(
d
-3) plus 4 spaces |
| | |
| . | . |
| | |
| . | . |
| | |
| 10(d-1) <= intlvalue < 10d | F(
w
-4).0 plus 4 spaces |
| | |
| 10d <= intlvalue | Ew.d |
| | |
-------------------------------------------------------------------------------------------
In general, if the number of integer digits in intlvalue is
greater than decplaces or equal to zero, kind = 1 is used (the
E
w.d
format).
Examples
The following examples show how the G
w.d
format is used.
If you specify the format G12.6 and the value of intlvalue is
1234.5, the equivalent F
w.d
format is calculated as follows:
because 103 < intlvalue < 104 , the format used is F(
w-
4).(
d-
4)
plus four spaces. Therefore, in this example, the equivalent F
w.d
format is F8.2 plus four spaces; the value stored is Å1234.50ÅÅÅÅ.
If you specify the format G13.7 and the value of intlvalue is
123456.7, the equivalent F
w.d
format is F(
w-4
).(
d-6
). Therefore,
in this example, the format used is F9.1 plus four spaces; the
value stored is Å123456.7ÅÅÅÅ.
Finally, if you specify the format G9.2 and the value of intlvalue
is 123.4, the equivalent E
w.d
format is E9.2; the value stored is
ÅÅ.12E+03.
3. The scale parameter does not affect kind = 0. When kind = 1 or 2,
the result string uses these factors:
* The internal representation value fraction is multiplied by
10s (where
s
is scale).
* The internal representation value exponent is reduced by
scale.
* When scale is <= zero, the charstring fraction has -scale
leading zeros, followed by decplaces + scale significant
digits.
* When scale is < zero, charstring has scale significant digits
to the left of the decimal point and (decplaces - scale) + 1
significant digits to the right of the decimal point.
* The least significant digit in charstring is rounded.
For example, if intlvalue = 1234.5, kind = 1, fieldwidth = 11, and