ISHC (integer, shift)
Class: Elemental function - Generic
Rotates an integer left or right by specified number of bits. Bits
shifted out one end are shifted in the other end. No bits are
lost.
The "shift" is of type integer; it is the direction and distance of
rotation.
If "shift" is positive, "integer" is rotated left "shift" bits. If
"shift" is negative, "integer" is rotated right "shift" bits. Bits
shifted out one end are shifted in the other. No bits are lost.
The kind of integer is important in circular shifting. With an
INTEGER(4) argument, all 32 bits are shifted. If you want to
rotate a one-byte or two-byte argument, you must declare it as
INTEGER(1) or INTEGER(2).
Examples:
Consider the following:
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHC (i, -3) ! returns 01000001 = 65
res2 = ISHC (j, -3) ! returns 01000000 00000001 = 16385