HTBasic Help
×
Menu
Index

ROTATE

Shifts a 16 bit binary value with wraparound.
 
 ROTATE( numeric-expression, distance )
 
 
Usage:
B1=ROTATE(B2,5)
Word=ROTATE(Word,Places)
Example: ROTATE.BAS
Description:
The numeric expression is rounded to an integer. The resulting integer, in binary form, is rotated the specified distance. The distance must be in the range 0 to ±15. If the distance is positive, then bits are moved to the right. Any bits moved out of the right-most bit (the least significant bit) are moved into the left-most bit (the most significant bit). If the distance is negative, then bits are moved to the left. Any bits moved out of the left-most bit are moved into the right-most bit.
For ROTATE(100,5) the number 100 is treated as a binary number and is rotated right five bits as follows:
100                = 0000000001100100
ROTATE(100,5)                = 0010000000000011
The result is returned as the decimal integer, 8195.
See Also: