Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

ISHL

Elemental Intrinsic Function (Generic): Logically shifts an integer left or right by the specified bits. Zeros are shifted in from the opposite end.

result = ISHL (i,shift)

i

(Input) Must be of type integer. This argument is the value to be shifted.

shift

(Input) Must be of type integer. This argument is the direction and distance of shift.

If positive, i is shifted left (toward the most significant bit). If negative, i is shifted right (toward the least significant bit).

Results

The result type and kind are the same as i. The result is equal to i logically shifted by shift bits. Zeros are shifted in from the opposite end.

Unlike circular or arithmetic shifts, which can shift ones into the number being shifted, logical shifts shift in zeros only, regardless of the direction or size of the shift. The integer kind, however, still determines the end that bits are shifted out of, which can make a difference in the result (see the following example).

Example

  INTEGER(1) i, res1
  INTEGER(2) j, res2
  i = 10   ! equal to 00001010
  j = 10   ! equal to 00000000 00001010
  res1 = ISHL (i, 5)   ! returns 01000000 = 64
  res2 = ISHL (j, 5)   ! returns 00000001 01000000 = 320

See Also