Binary, octal, hexadecimal, and Hollerith constants have no intrinsic data type. These constants 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)
| None | 9 |
When a binary, octal, or hexadecimal constant is used in any other context, the default integer data type is assumed (default integer can be affected by compiler options). 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:
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.
Table 16-2 lists the number of bytes that each data type requires.
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, an error occurs.
Each Hollerith character occupies one byte of memory.
For More Information:
For details on compiler options, see your user manual or programmer's guide.