HTBasic Help
×
Menu
Index

SHIFT

Shifts a 16 bit binary value.
 
 SHIFT( numeric-expression, distance )
 
 
Usage:
Check=SHIFT(Word1,Place)
K=SHIFT(100,-6)
Example: SHIFT.BAS
Description:
The numeric expression is rounded to an integer. The resulting integer, in binary form, is shifted the specified distance. The distance must be in the range ±15. If the distance is positive, bits are moved to the right. Any bits moved out of the right-most bit (the least significant bit) are discarded and zero bits are shifted into the left-most bit (the most significant bit). If the distance is negative, bits are moved to the left. Any bits moved out of the left-most bit are discarded and zero bits are shifted into the right-most bit.
For SHIFT(100,5) the number 100 is treated as a binary number and is shifted right five bits as follows:
100                = 0000000001100100
SHIFT(100,5)                = 0000000000000011
The result is returned as the decimal integer, 3.
See Also: