HP Fortran Programmer's Reference (September 2007)

Data types and data objects
Intrinsic data types
Chapter 5 115
where
leading-letter
is the single character B, O, or Z, indicating binary, octal, or
hexadecimal base, respectively.
digit-string
must consist of digits that can represent the
base, namely:
Binary: 0 and 1.
Octal: 0 through 7.
Hexadecimal: 0 through 9, and A through F. The letters can be uppercase or lowercase.
In the following, the three DATA statements use BOZ constants to initialize i, j, and k to the
decimal value 74:
INTEGER i, j, k
DATA i/B'01001010'/
DATA j/O'112'/
DATA k/Z'4A'/
As an extension, HP Fortran allows octal constants with a trailing O, and hexadecimal
constants with a trailing X. The following DATA statements initialize j and k to the decimal
value 74:
DATA j/'112'O/
DATA k/'4A'X/
HP Fortran also allows the use of BOZ constants in contexts other than the DATA statement;
see “Typeless constants” on page 116.
Hollerith constants
Hollerith constants have the form:
len
H
string
where
len
is the number of characters in the constant and
string
contains exactly
len
characters. The value of the constant is the value of the pattern of bytes generated by the
ASCII values of the characters.
As an extension, HP Fortran allows Hollerith constants to appear in the same contexts as
BOZ constants (see “Typeless constants” on page 116), as well as wherever a character string
is valid. If
len
is greater than the number of characters in
string
, the constant is padded on
the right with space characters. If
len
is less than the number of characters in
string
, the
constant is truncated on the right.
If a Hollerith constant appears as an argument to the conversion functions INT and LOGICAL,
the kind parameter is KIND=1 if the length of the constant is 1 byte, KIND=2 if the length is 2
bytes, KIND=4 if 3 0r 4 bytes, and KIND=8 if greater than 4.
Following are examples of Hollerith constants:
3HABC