bitshift
bitshift |
Purpose
Synopsis
function bitshift(i:integer, n:integer):integer
Arguments
i
|
Integer to be shifted
|
n
|
Number of bits: >0 for shifting to the left and <0 for shifting to the right
|
Return value
Shifted integer.
Example
In the following,
i takes the value 160,
j takes the value 32, and
k takes the value 1:
i:= bitshift(5, 5) j:= bitshit(1, 5) k:= bitshit(128, -7)
Further information
Shifting of 1 bit to the right is the same as dividing it by 2 and shifting of 1 bit to the left is the same as multiplying by 2.
Related topics