Besides decimal constants, Fortran also supports binary (
o) and hexadecimal (
z) integer constants. The
syntax is: ‘prefix quote digits quote’, were the prefix is
z, quote is either
" and the digits are
1 for binary,
7 for octal, and between
F for hexadecimal. (Example:
Up to Fortran 95, BOZ literal constants were only allowed to initialize
integer variables in DATA statements. Since Fortran 2003 BOZ literal
constants are also allowed as actual arguments to the
CMPLX intrinsic functions.
The BOZ literal constant is simply a string of bits, which is padded
or truncated as needed, during conversion to a numeric type. The
Fortran standard states that the treatment of the sign bit is processor
dependent. Gfortran interprets the sign bit as a user would expect.
As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal
constants to be specified using the
X prefix. The BOZ literal
constant can also be specified by adding a suffix to the string, for
'ABC'X are equivalent.