Intel fortran-80 manual Arithmetic Assignment Statement, Type Of, TYPE OF exp, Result

Models: fortran-80

1 130
Download 130 pages 742 b
Page 34
Image 34
3.3.1 Arithmetic Assignment Statement

Defining Variables, Arrays, And Memory

FORTRAN-80

3.3.1 Arithmetic Assignment Statement

The arithmetic assignment statement closely resembles a conventional arithmetic formula. Its format is:

v = exp

where

vis the name of a variable or array element of type integer or real

I

exp is an arithmetic expression

The' ='in FORTRAN has the sense 'is assigned the value' rather than 'is equal to.' Thus

I = 1+1

is a perfectly correct FORTRAN statement.

Execution of an arithmetic assignment statement causes evaluation of the expression 'exp' according to the rules listed in Chapter 2 (see Figures 2-2 and 2-3), conversion of 'exp' to the type of 'v,' and definition and assignment of 'v' with the resulting value, as shown in Figure 3-2. IFIX and FLOAT in this figure are intrinsic functons for converting a real number to an integer and an integer to a real number, respec- tively.

TYPE OF 'v'

TYPE OF 'exp'

 

RESULT

 

 

 

 

INTEGER

INTEGER

 

exp

REAL

REAL

 

exp

INTEGER

REAL

 

IFIX (exp)

REAL

INTEGER

 

FLOAT (exp)

 

 

 

 

 

f'i~. 3-2 Result of 'v = exp'

 

Example:

 

 

 

1=3

 

 

 

C = I + SQRT(25.0)

C = C**2

C AS A RESULT OF THESE CALCULATIONS C = 64.0

If the value of 'exp' is too large to be assigned to 'v' the result is undefined. This may happen when the length of 'v' is too short to contain the processor representa- tion of the integer value (see section F.l).

If the length of 'v' is longer, the length of 'exp' is converted to the length of 'v' while preserving its value.

Example:

INTEGER* 1 M(1000)

INTEGER*4 N

N= 65 M(200) = N

C LENGTH OF IN'IS CONVERTED TO ONE BYTE

3-8

Page 34
Image 34
Intel fortran-80 manual Arithmetic Assignment Statement, Type Of, TYPE OF exp, Result