For numeric assignment statements, the variable and expression must be numeric type.

The expression must yield a value that conforms to the range requirements of the variable. For example, a real expression that produces a value greater than 32767 is invalid if the entity on the left of the equal sign is an INTEGER(2) variable.

Significance can be lost if an INTEGER(4) value, which can exactly represent values of approximately the range -2*10**9 to +2*10**9, is converted to REAL(4) (including the real part of a complex constant), which is accurate to only about seven digits.

If the variable has the same data type as that of the expression on the right, the statement assigns the value directly. If the data types are different, the value of the expression is converted to the data type of the variable before it is assigned.

Figure 4-1 summarizes the data conversion rules for numeric assignment statements. REAL(16) is only available on OpenVMS and Tru64 UNIX systems.

The following examples demonstrate valid and invalid numeric assignment statements:

Valid | |

```
BETA = -1./(2.*X)+A*A
/(4.*(X*X))
``` | |

```
PI =
3.14159
``` | |

```
SUM
= SUM + 1.
``` | |

`ARRAY_A = ARRAY_B + ARRAY_C + SCALAR_I` |
! Valid if all arrays conform in ! shape |

Invalid |
Explanation |

```
3.14
= A - B
``` | Entity on the left must be a variable. |

`ICOUNT = A//B(3:7)`
| Implicitly typed data types do not match. |

`SCALAR_I = ARRAY_A(:)` |
Shapes do not match. |

Previous Page Next Page Table of Contents