Elemental Intrinsic Function (Generic): Performs a logical shift.
Syntax
Results:
The result type is 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. ISHFT with a negative shift can also be specified as RSHIFT with |shift|.
For more information, 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 |
---|---|---|
INTEGER(1) | INTEGER(1) | |
IISHFT | INTEGER(2) | INTEGER(2) |
JISHFT | INTEGER(4) | INTEGER(4) |
KISHFT | INTEGER(8) | INTEGER(8) |
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: BIT_SIZE, ISHFTC, ISHA, ISHC
Examples
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/