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

ID 767251
Date 7/13/2023
Public

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

Document Table of Contents

ISHFT

Elemental Intrinsic Function (Generic): Performs a logical shift.

result = ISHFT (i,shift)

i

(Input) Must be of type integer.

shift

(Input) Must be of type integer. The absolute value for shift must be less than or equal to BIT_SIZE( i).

Results

The result type and kind are the same as i. The result has the value obtained by shifting the bits of i by shift positions. If shift is positive, the shift is to the left; if shift is negative, the shift is to the right. If shift is zero, no shift is performed.

Bits shifted out from the left or from the right, as appropriate, are lost. Zeros are shifted in from the opposite end.

ISHFT with a positive shift can also be specified as LSHIFT (or LSHFT). ISHFT with a negative shift can also be specified as RSHIFT (or RSHFT) with | shift |.

For more information on bit functions, see Bit Functions.

The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.

Specific Name

Argument Type

Result Type

BSHFT

INTEGER(1)

INTEGER(1)

IISHFT1

INTEGER(2)

INTEGER(2)

JISHFT

INTEGER(4)

INTEGER(4)

KISHFT

INTEGER(8)

INTEGER(8)

1Or HSHFT.

Example

ISHFT (2, 1) has the value 4.

ISHFT (2, -1) has the value 1.

The following shows another example:

  INTEGER(1) i, res1
  INTEGER(2) j, k(3), res2
  i = 10 ! equal to 00001010
  j = 10 ! equal to 00000000 00001010
  res1 = ISHFT (i, 5)  ! returns 01000000 = 64
  res2 = ISHFT (j, 5)  ! returns 00000001 01000000 =
                       ! 320
  k = ISHFT((/3, 5, 1/), (/1, -1, 0/))  ! returns array
                                        ! /6, 2, 1/