Intel® Fortran Compiler 16.0 User and Reference Guide

Determining the Data Type of Nondecimal Constants

Binary, octal, hexadecimal, and Hollerith constants have no intrinsic data type. In most cases, the default integer data type is assumed.

However, these constants can assume a numeric data type depending on their use. When the constant is used with a binary operator (including the assignment operator), the data type of the constant is the data type of the other operand. For example:

Statement

Data Type of Constant

Length of Constant (in bytes)

INTEGER(2) ICOUNT

INTEGER(4) JCOUNT

INTEGER(4) N

REAL(8) DOUBLE

REAL(4) RAFFIA, RALPHA

RAFFIA = B'1001100111111010011'

REAL(4)

4

RAFFIA = Z'99AF2'

REAL(4)

4

RALPHA = 4HABCD

REAL(4)

4

DOUBLE = B'1111111111100110011010'

REAL(8)

8

DOUBLE = Z'FFF99A'

REAL(8)

8

DOUBLE = 8HABCDEFGH

REAL(8)

8

JCOUNT = ICOUNT + B'011101110111'

INTEGER(2)

2

JCOUNT = ICOUNT + O'777'

INTEGER(2)

2

JCOUNT = ICOUNT + 2HXY

INTEGER(2)

2

IF (N .EQ. B'1010100') GO TO 10

INTEGER(4)

4

IF (N .EQ. O'123') GO TO 10

INTEGER(4)

4

IF (N. EQ. 1HZ) GO TO 10

INTEGER(4)

4

When a specific data type (generally integer) is required, that type is assumed for the constant. For example:

Statement

Data Type of Constant

Length of Constant (in bytes)

Y(IX) = Y(O'15') + 3.

INTEGER(4)

4

Y(IX) = Y(1HA) + 3.

INTEGER(4)

4

When a nondecimal constant is used as an actual argument, the following occurs:

For example:

Statement

Data Type of Constant

Length of Constant (in bytes)

CALL APAC(Z'34BC2')

INTEGER(4)

4

CALL APAC(9HABCDEFGHI)

REAL(16)

9

When a binary, octal, or hexadecimal constant is used in any other context, the default integer data type is assumed. In the following examples, default integer is INTEGER(4):

Statement

Data Type of Constant

Length of Constant (in bytes)

IF (Z'AF77') 1,2,3

INTEGER(4)

4

IF (2HAB) 1,2,3

INTEGER(4)

4

I = O'7777' - Z'A39' 1

INTEGER(4)

4

I = 1HC - 1HA

INTEGER(4)

4

J = .NOT. O'73777'

INTEGER(4)

4

J = .NOT. 1HB

INTEGER(4)

4

1 When two typeless constants are used in an operation, they both take default integer type.

When nondecimal constants are not the same length as the length implied by a data type, the following occurs: