The G data edit descriptor generally transfers values of real type, but it can be used to transfer values of any intrinsic type. It takes the following form:
Gw.d[Ee]
The value of d (the number of places after the decimal point) plus e (the number of digits in the exponent) must not exceed the value of w (the field width), unless w is zero. If w is zero, you can only specify forms G0 or G0.d.
When w is zero, the processor selects the field width. On input, w must not be zero.
The specified I/O list item can be of any intrinsic type.
When used to specify I/O for integer, logical, or character data, the edit descriptor follows the same rules as Iw, Lw, and Aw, respectively, and d and e have no effect.
On input, the G data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. The G descriptor interprets and assigns input data in the same way as the F data edit descriptor.
On output, the G data edit descriptor transfers the real value of the corresponding I/O list item, right-justified and rounded to d decimal positions, to an external field that is w characters long.
The form in which the value is written is a function of the magnitude of the value, as described in the following table:
Data Magnitude |
Effective Conversion |
---|---|
0 < m < 0.1 - 0.5 x 10-d-1 |
Ew.d[Ee] |
m = 0 |
F(w - n).(d -1), n('b') |
0.1 - 0.5 x 10-d-1 m < 1 - 0.5 x 10-d |
F(w - n).d, n('b') |
1 - 0.5 x 10-d m < 10 - 0.5 x 10-d+1 |
F(w - n).(d -1), n('b') |
10 - 0.5 x 10-d+1 m < 100 - 0.5 x 10-d+2 |
F(w - n).(d -2), n('b') |
. |
. |
. |
. |
. |
. |
10d-2 - 0.5 x 10-2 m < 10d-1 - 0.5 x 10-1 |
F(w - n).1, n('b') |
10d-1 - 0.5 x 10-1 m < 10d - 0.5 |
(w - n).0, n('b') |
m 10d - 0.5 |
Ew.d[Ee] |
The 'b' is a blank following the numeric data representation. For Gw.d, n('b') is 4 blanks. For Gw.dEe, n('b' ) is e+2 blanks.
The w should be greater than or equal to d+7 to allow for the following:
A sign (optional if the value is positive and descriptor SP is not in effect)
One digit to the left of the decimal point
The decimal point
The d digits to the right of the decimal point
The 4-digit or e+2-digit exponent
If e is specified, the w should be greater than or equal to d + e + 5.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for Fw.d.
The following shows output using the G edit descriptor and compares it to output using equivalent F editing (the symbol ^ represents a nonprinting blank character):
Value Format Output with G Format Output with F
0.01234567 G13.6 ^0.123457E-01 F13.6 ^^^^^0.012346
-0.12345678 G13.6 -0.123457^^^^ F13.6 ^^^^-0.123457
1.23456789 G13.6 ^^1.23457^^^^ F13.6 ^^^^^1.234568
12.34567890 G13.6 ^^12.3457^^^^ F13.6 ^^^^12.345679
123.45678901 G13.6 ^^123.457^^^^ F13.6 ^^^123.456789
-1234.56789012 G13.6 ^-1234.57^^^^ F13.6 ^-1234.567890
12345.67890123 G13.6 ^^12345.7^^^^ F13.6 ^12345.678901
123456.78901234 G13.6 ^^123457.^^^^ F13.6 123456.789012
-1234567.89012345 G13.6 -0.123457E+07 F13.6 *************
Copyright © 1996-2010, Intel Corporation. All rights reserved.