ISO/IEC JTC1/SC22/WG5 N1695
Bit Manipulation Features
Bill Long
Even though the BITS intrinsic data type is recommended for removal
from the Fortran 2008 draft standard, these related features are
recommended for retention or addition:
1) Retain these intrinsics beyond those in Fortran 2003:
DSHIFTL
DSHIFTR
IALL
IANY
IPARITY
LEADZ
MASKL
MASKR
MERGE_BITS
PARITY
POPCNT
POPPAR
SHIFTA
SHIFTL
SHIFTR
TRAILZ
2) Add four new intrinsic function that provide relational bit
sequence comparisons of integer values based on their
interpretation as bit sequences:
BGE (I,J) - bits compare greater or equal
BGT (I,J) - bits compare greater
BLE (I,J) - bits compare less or equal
BLT (I,J) - bits compare less
The result value is computed by the algorithm in paragraph 12 of
7.1.5.6.1 Interpretation of relational intrinsic operations,
[162:20-22], in N1678. Either or both of the arguments may be BOZ
literal constants.
3) Retain the ability for formatted input and output of values of type
REAL or COMPLEX using the Z, O, or B edit descriptors.
Subclause 10.7.2.4 Bits editing, [285:1-24], in N1678 is the basis
for this capability, with edits to restrict the allowed data types
to integer, real, and complex (as a pair of reals), to change the
description of how the objects are interpreted as bit sequences, and
to change the subclause heading to "BOZ editing".
4) Retain BOZ literal constants as allowed arguments to these
intrinsic functions:
DSHIFTL (I,J,SHIFT)
DSHIFTR (I,J,SHIFT)
IAND (I,J)
IEOR (I,J)
IOR (I,J)
MERGE_BITS (I,J,MASK)
For each of these functions, either, but not both, of the I or J
arguments may be a BOZ literal constant. If I is of type integer
and J is a BOZ literal constant, then the result of IAND (I,J) is
equal to IAND (I, INT(J, KIND=KIND(I))), with corresponding results
for the other functions. Similarly for J of type integer and I a
BOZ literal constant. In the case of MERGE_BITS, the MASK argument
may also be a BOZ literal constant. The result value is computed as
if the MASK were converted to type integer with the same effective
kind type parameter as the I and J arguments.