# ISHC

Elemental Intrinsic 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.

result = ISHC (i,shift)

i | (Input) Must be of type integer. This argument is the value to be rotated.
shift | (Input) Must be of type integer. This argument is the direction and distance of rotation. Positive rotations are left (toward the most significant bit); negative rotations are right (toward the least significant bit).

## Results

The result type and kind are 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).

## Example

      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

Parent topic: H to I

## See Also

ISHA
ISHL
ISHFT
ISHFTC