### 2.2.1.7 Hollerith Constants

A Hollerith constant is a string of printable ASCII characters preceded by a character count and the letter H. It takes the following form:

    nHc1c2c3 . . . cn

n
  Is an unsigned, nonzero integer constant stating the number of characters in the string (including spaces and tabs).
cn
  Is a printable ASCII character.

Hollerith constants are strings of 1 to 2000 characters. They are stored as byte strings, one character per byte.

Examples

The following examples show valid and invalid Hollerith constants:

Valid |
`16HTODAY'S DATE IS:` |
`1HB` |
`4H ABC` |
Invalid | Explanation
`3HABCD` | Wrong number of characters
`0H` | Hollerith constants must contain at least one character

Data-Typing Hollerith Constants

Hollerith constants have no data type. They assume a numeric data type based on the way they are used. Hollerith constants cannot assume a character data type and cannot be used where a character value is expected.

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` |  |
`REAL*8 DOUBLE` |  |
`RALPHA = 4HABCD` | REAL*4 | 4
`JCOUNT = ICOUNT + 2HXY` | INTEGER*2 | 2
`DOUBLE = 8HABCDEFGH` | REAL*8 | 8
`IF (N. EQ. 1HZ) GO TO 10` | INTEGER*4 | 4

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

Statement | Data Type of Constant | Length of Constant (in bytes)
--- | --- | ---
`Y(IX) = Y(1HA) + 3.` | INTEGER*4 | 4

When the constant is used as an actual argument, no data type is assumed. For example:

Statement | Data Type of Constant | Length of Constant (in bytes)
--- | --- | ---
`CALL APAC(9HABCDEFGHI)` | None | 9

When the constant is used in any other context, an INTEGER*4 data type is assumed (unless compiler option INTEGER_SIZE specifies otherwise). For example:

Statement | Data Type of Constant | Length of Constant (in bytes)
--- | --- | ---
`IF (2HAB) 1,2,3` | INTEGER*4 | 4
`I = 1HC - 1HA` | INTEGER*4 | 4
`J = .NOT. 1HB` | INTEGER*4 | 4

When the length of the constant is less than the length implied by the data type, spaces 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. An error results if any characters other than space characters are truncated.

Each character occupies one byte of memory.

For More Information:

- On compiler options, in general, see your user manual.

- On names of compiler options used in this manual, see Section E.4.

- On the number of characters required for each data type, see Section 2.1.

Previous Page Next Page Table of Contents