# F Editing

The F data edit descriptor transfers real values. It takes the following form:

Fw.d

The value of d (the number of places after the decimal point) must not exceed the value of w (the field width) unless w is zero. When w is zero, the processor selects the field width. On input, w must not be zero.

The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.

## Rules for Input Processing

On input, the F data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. The external field data must be an integer or real constant.

An input field is one of the following:

- An IEEE exception specification

- An hexadecimal-significand number

- An optional sign, followed by a string of one or more digits optionally containing a decimal symbol; any blanks are interpreted as zeros.

The basic form can be followed by an exponent in one of the following forms:

- A sign followed by one or more digits

- An E or D followed by zero or more blanks, followed by an optional sign and one or more digits

An exponent containing a D is processed in the same way as an exponent containing an E.

If the input field contains only an exponent letter or decimal point, it is treated as a zero value.

If the input field does not contain a decimal point or an exponent, it is treated as a real number of w digits, with d digits to the right of the decimal point. (Leading zeros are added, if necessary.)

If the input field contains a decimal point, the location of that decimal point overrides the location specified by the F descriptor.

If the field contains an exponent, that exponent is used to establish the magnitude of the value before it is assigned to the list element.

An input field that is an IEEE exception specification consists of optional blanks, followed by either of the following:

- An optional sign, followed by the string 'INF' or the string 'INFINITY'; this is an IEEE infinity

  This form can not be used if the processor does not support IEEE infinities for the input variable.

- An optional sign, followed by the string 'NAN', optionally followed by zero or more alphanumeric characters enclosed in parentheses, optionally followed by blanks; this is an IEEE Nan

  This form can not be used if the processor does not support IEEE Nans for the input variable.

The NaN value is a quiet NaN if the only nonblank characters in the field are 'NAN' or 'NAN()'.

An input field that is a hexadecimal-significand number contains an optional sign, followed by the digit 0, followed immediately by the letter X, followed by the hexadecimal significand followed by a hexadecimal exponent. A hexadecimal significand is a string of one or more hexadecimal characters, optionally containing a decimal symbol. The position of the hexadecimal point is indicated by the decimal symbol. The hexadecimal point implicitly follows the last hexadecimal character if decimal symbol appears in the string. A hexadecimal exponent is the letter P followed by a signed decimal digit string. Embedded blanks are not allowed; trailing blanks are ignored. The value is equal to the significand multiplied by two raised to the power of the exponent. If the optional sign is a minus, the value is negated.

The following shows input using the F edit descriptor:

    Format    Input         Value
    F8.5      123456789       123.45678
    F8.5      -1234.567     -1234.56
    F8.5      24.77E+2       2477.0
    F5.2      1234567.89      123.45

## Rules for Output Processing

On output, the F 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.

For an internal value that is an IEEE infinity, the output field consists of blanks, if needed, followed by a sign (optional if the value is positive and descriptor SP is not in effect), followed by the letters 'Inf' or 'Infinity', right justified within the field.

If w is less than 3, the field is filled with asterisks; otherwise, if w is less than 8, 'Inf' is produced.

For an internal value that is an IEEE NaN, the output field consists of blanks, if necessary, followed by the letters 'NaN' and optionally followed by one to w − 5 alphanumeric characters enclosed in parentheses, right justified within the field.

If w is less than 3, the field is filled with asterisks.

For an internal value that is neither an IEEE infinity nor an IEEE NaN, the w must be greater than or equal to d+3 to allow for the following:

- A sign (optional if the value is positive and descriptor SP is not in effect)

- At least one digit to the left of the decimal point

- The decimal point

- The d digits to the right of the decimal point

A negative value that is not zero but rounds to zero on output is displayed with a leading minus sign. For example, the value -0.00000001 in F5.1 format will be displayed as -0.0 rather than as 0.0. The setting of compiler option assume [no]std_minus0_rounding can affect this behavior.

The following shows output using the F edit descriptor (the symbol ^ represents a nonprinting blank character):

    Format      Value             Output
    F8.5           2.3547188      ^2.35472
    F9.3        8789.7361         ^8789.736
    F2.1          51.44           **
    F10.4        -23.24352        ^^-23.2435
    F5.2         325.013          ******
    F5.2           -.2            -0.20

Parent topic: Real and Complex Editing

## See Also

Forms for data edit descriptors
General rules for numeric editing
assume compiler option