Intel® Fortran Compiler 18.0 Developer Guide and Reference
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:
When binary, octal, and hexadecimal constants are specified as arguments to intrinsic functions, and the description of the function specifies the interpretation of such constants, that specified interpretation is used.
For binary, octal, and hexadecimal constants in other actual argument contexts, if the value fits in a default integer, that integer kind is used. Otherwise, the smallest integer kind large enough to hold the value is used.
For Hollerith constants, a numeric data type of sufficient size to hold the length of the constant is assumed.
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:
Binary, octal, and hexadecimal constants
These constants can specify up to 16 bytes of data. When the length of the constant is less than the length implied by the data type, the leftmost digits have a value of zero.
When the length of the constant is greater than the length implied by the data type, the constant is truncated on the left. An error results if any nonzero digits are truncated.
The Data Type Storage Requirements table lists the number of bytes that each data type requires.
Hollerith constants
When the length of the constant is less than the length implied by the data type, blanks are appended to the constant on the right.
When the length of the constant is greater than the length implied by the data type, the constant is truncated on the right. If any characters other than blank characters are truncated, a warning occurs.
Each Hollerith character occupies one byte of memory.