# Function Reference

BitRotate

Performs a bit shifting operation, with rotation.

BitRotate ( value , shift [, size] )

Parameters

 value The number to be operate on. shift Number of bits to rotate to the left (negative numbers shift right). If not given, the default is 1. size [optional] A string that determines the rotation size, the default is (16 bits). See below.

Size parameter :
 "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 entire double-word (32 bits).

Return Value

 Success: Returns the value rotated by the required number of bits. Failure: Set @error if size is invalid
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.

Related

BitShift, BitAND, BitNOT, BitOR, BitXOR, Hex

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