Lahey/Fujitsu Fortran

ISHFT Function

Description

The ISHFT function performs an end-off bit shift on an integer argument.

Syntax

ISHFT (i, shift)

Arguments

i is an INTENT(IN) scalar or array of type INTEGER.

shift is an INTENT(IN) scalar or array of type INTEGER. Its absolute value must be less than or equal to the number of bits in i.

Result

The result is of type INTEGER and of the same kind as i.

Its value is the value of i shifted by shift positions; if shift is positive, the shift is to the left, if shift is negative, the shift is to the right.

Bits shifted off are lost.

Example

integer :: i=16,ia(2)=(/4,8/) write(*,*) i, ia ! writes 16 4 8 write(*,*) ishft(i,-2) ! writes 4 write(*,*) ishft(i,ia) ! writes 256 4096 write(*,*) ishft(ia,2) ! writes 16 32 write(*,*) ishft(ia,i) ! writes 262144 524288