Besides decimal constants, Fortran also supports binary (
o) and hexadecimal (
z) integer constants. The
syntax is: ‘prefix quote digits quote’, where 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. That the BOZ literal
constant can also be specified by adding a suffix to the string, for
'ABC'X are equivalent. Additionally,
as extension, BOZ literals are permitted in some contexts outside of
DATA and the intrinsic functions listed in the Fortran standard.
Use -fallow-invalid-boz to enable the extension.