|Description:||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.|
|Class:||Elemental function; Generic|
|Arguments:||I||Must be of type integer. This argument is the value to be rotated.|
be of type integer. This argument is the direction and distance of
Positive rotations are left (toward the most significant bit); negative rotations are right (toward the least significant bit).
|Results:||The result type is the same as I. The
result is equal to I circularly rotated by SHIFT bits.
If SHIFT is positive, I is rotated left SHIFT bits. If SHIFT is negative, I 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).
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