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

ID 767251
Date 3/22/2024
Public

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

Document Table of Contents

ISHFTC

Elemental Intrinsic Function (Generic): Performs a circular shift of the rightmost bits.

result = ISHFTC (i,shift[,size])

i

(Input) Must be of type integer.

shift

(Input) Must be of type integer. The absolute value of shift must be less than or equal to size. 1

size

(Input; optional) Must be of type integer. The value of size must be positive2 and must not exceed BIT_SIZE( i). If size is omitted, it is assumed to have the value of BIT_SIZE( i).

1SHIFT can be a value whose absolute value is greater than SIZE. In this case, the effect is as if SHIFT has the value MOD (SHIFT, SIZE) if SIZE is positive.

2SIZE can be zero. In this case, no circular shift is performed and the function result is the value of i, the first argument.

Results

The result type and kind are the same as i. The result value is obtained by circular shifting the size rightmost 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.

No bits are lost. Bits in i beyond the value specified by size are unaffected.

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

BSHFTC

INTEGER(1)

INTEGER(1)

IISHFTC3

INTEGER(2)

INTEGER(2)

JISHFTC

INTEGER(4)

INTEGER(4)

KISHFTC

INTEGER(8)

INTEGER(8)

3Or HSHFTC.

Example

ISHFTC (4, 2, 4) has the value 1.

ISHFTC (3, 1, 3) has the value 6.

The following shows another example:

  INTEGER(1) i, res1
  INTEGER(2) j, res2
  i = 10  ! equal to 00001010
  j = 10  ! equal to 00000000 00001010
  res1 = ISHFTC (i, 2, 3)   ! rotates the 3 rightmost
                            ! bits by 2 (left) and
                            ! returns 00001001 = 9
  res1 = ISHFTC (i, -2, 3)  ! rotates the 3 rightmost
                            ! bits by -2 (right) and
                            ! returns 00001100 = 12
  res2 = ISHFTC (j, 2, 3)   ! rotates the 3 rightmost
                            ! bits by 2 and returns
                            ! 00000000 00001001 = 9

See Also