BitRotate
From AutoIt Wiki
Performs a bit shifting operation with rotation. Adapted from AutoIt docs.
Contents |
Syntax
$x = BitRotate(value, shift [, size])
Parameters
| value | The number to shift. |
| shift | Number of bits to rotate. Default 1. |
| size | A string that determines the rotation size.(Optional) |
Shift
Shift will rotate to the right if negative and left if positive.
Size
Defaults to 16 bits. Otherwise the size parameter may be set to the following:
| B | rotate bits within the low-order byte (8 bits) |
| W | rotate bits within the low-order word (16 bits) |
| D | rotate bits within the double word (32 bits) |
Return Value
Returns the value rotated by the required number of bits. Bit operations are performed as 32-bit integers.
Example
$x = BitRotate(7, 2) ; x == 3 because 111b left-rotated twice is 1 1100b == 28 $y = BitRotate(14, -2) ; y == 32771 because 1110b right-rotated twice on 16 bits is 1000 0000 0000 0011b == 32771 $z = BitRotate(14, -2, "D") ; z == -2147483645 because 1110b right-rotated twice on 16 bits is 1000 0000 0000 0000 0000 0000 0000 0011b == 2147483645