## 11.3.5 Scale Factor Editing (P)

The P edit descriptor specifies a scale factor, which moves the location of the decimal point in real values and the two real parts of complex values. It takes the following form:

  kP

The k is a signed (sign is optional if positive), integer literal constant specifying the number of positions, to the left or right, that the decimal point is to move (the scale factor). The range of k is -128 to 127.

At the beginning of a formatted I/O statement, the value of the scale factor is zero. If a scale editing descriptor is specified, the scale factor is set to the new value, which affects all subsequent real edit descriptors until another scale editing descriptor occurs.

To reinstate a scale factor of zero, you must explicitly specify 0P.

Format reversion does not affect the scale factor. (For more information on format reversion, see Section 11.8.)

Rules for Input Processing

On input, a positive scale factor moves the decimal point to the left, and a negative scale factor moves the decimal point to the right. (On output, the effect is the reverse.)

On input, when an input field using an F, E, D, EN, ES, or G real edit descriptor contains an explicit exponent, the scale factor has no effect. Otherwise, the internal value of the corresponding I/O list item is equal to the external field data multiplied by 10-k. For example, a 2P scale factor multiplies an input value by .01, moving the decimal point two places to the left. A -2P scale factor multiplies an input value by 100, moving the decimal point two places to the right.

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

    Format    Input         Value
    3PE10.5   ^^^37.614^         .037614
    3PE10.5   ^^37.614E2     3761.4
    -3PE10.5  ^^^^37.614    37614.0

The scale factor must precede the first real edit descriptor associated with it, but it need not immediately precede the descriptor. For example, the following all have the same effect:

      (3P, I6, F6.3, E8.1)
      (I6, 3P, F6.3, E8.1)
      (I6, 3PF6.3, E8.1)

Note that if the scale factor immediately precedes the associated real edit descriptor, the comma separator is optional.

Rules for Output Processing

On output, a positive scale factor moves the decimal point to the right, and a negative scale factor moves the decimal point to the left. (On input, the effect is the reverse.)

On output, the effect of the scale factor depends on which kind of real editing is associated with it, as follows:

- For F editing, the external value equals the internal value of the I/O list item multiplied by 10k. This changes the magnitude of the data.
- For E and D editing, the external decimal field of the I/O list item is multiplied by 10k, and k is subtracted from the exponent. This changes the form of the data.

  A positive scale factor decreases the exponent; a negative scale factor increases the exponent.

  For a positive scale factor, k must be less than d + 2 or an output conversion error occurs.

- For G editing, the scale factor has no effect if the magnitude of the data to be output is within the effective range of the descriptor (the G descriptor supplies its own scaling).

  If the magnitude of the data field is outside G descriptor range, E editing is used, and the scale factor has the same effect as E output editing.

- For EN and ES editing, the scale factor has no effect.

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

    Format     Value         Output
    1PE12.3    -270.139      ^^-2.701E+02
    1P,E12.2   -270.139      ^^^-2.70E+02
    -1PE12.2   -270.139      ^^^-0.03E+04

The following shows a FORMAT statement containing a scale factor:

         DIMENSION A(6)
         DO 10 I=1,6
    10   A(I) = 25.
         WRITE (6, 100) A
    100  FORMAT(' ', F8.2, 2PF8.2, F8.2)

The preceding statements produce the following results:

        25.00  2500.00  2500.00
      2500.00  2500.00  2500.00

Previous Page Next Page Table of Contents