2.3.1.2 Data Type of an Arithmetic Expression

If every element in an arithmetic expression is of the same data type, the value produced by the expression is also of that data type. If elements of different data types are combined in an expression, the evaluation of that expression and the data type of the resulting value depend on the ranking associated with each data type. The following table shows the ranking assigned to each data type; the lowest ranking is 1:

Data Type  VAX Ranking  Alpha Ranking 
BYTE 
LOGICAL*1 
LOGICAL*2 
LOGICAL (LOGICAL*4) 
LOGICAL*8[1]  None 
INTEGER*1 
INTEGER*2 
INTEGER (INTEGER*4) 
INTEGER*8[1]  None 
REAL (REAL*4) 
DOUBLE PRECISION (REAL*8)  10 
REAL*16  11 
COMPLEX (COMPLEX*8)  12 
DOUBLE COMPLEX (COMPLEX*16)  10  13 

[1] Alpha only

The data type of the value produced by an operation on two arithmetic elements of different data types is the data type of the highest-ranking element in the operation. For example, the data type of the value resulting from an operation on an integer and a real element is real. However, an operation involving a COMPLEX data type and either a DOUBLE PRECISION or REAL*16 data type produces a DOUBLE COMPLEX result.

The data type of an expression is the data type of the result of the last operation in that expression and is determined according to the following conventions:

These rules also generally apply to arithmetic operations in which one of the operands is a constant. However, if a real or complex constant is used in a higher-precision expression, additional precision will be retained for the constant. The effect is as if a DOUBLE PRECISION (REAL*8) or REAL*16 representation of the constant is given. For example, the expression 1.0D0 + 0.3333333 is treated as if it is 1.0D0 + 0.3333333000000000D0.


Previous Page Next Page Table of Contents