# Function Reference

# BitRotate

Performs a bit shifting operation, with rotation.

BitRotate ( value [, shift = 1 [, size = "W"]] )

## Parameters

value | The number to be operate on.
shift | [optional] Number of bits to rotate to the left (negative numbers rotate 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: | the value rotated by the required number of bits.
Failure: | Sets the flag @error to non-zero if size is invalid.

## Remarks

Remember hex notation can be used for numbers.

## Related

BitAND, BitNOT, BitOR, BitShift, BitXOR, Hex

## Example

    #include <MsgBoxConstants.au3>

    Example()

    Func Example()
        ; Note: "b" is the symbol for byte.

        ; Assign a Local variable the bitwise left-rotate operation of 2.
        Local $iBitRotate1 = BitRotate(2, 1) ; 2 = 0010b left-rotated once -> 4 = 0100b

        ; Note: It is equivalent to do this: BitShift(2, -1)

        ; Display the result.
        MsgBox($MB_SYSTEMMODAL, "", $iBitRotate1)

        ; Assign a Local variable the bitwise right-rotate operation of 1.
        Local $iBitRotate2 = BitRotate(1, -1) ; 1 = 0001b right-rotated once -> 32768 (32 bits) = 1000 0000 0000 0000b

        ; Display the result.
        MsgBox($MB_SYSTEMMODAL, "", $iBitRotate2)

        ; Assign a Local variable the bitwise right-rotate operation of 14.
        Local $iBitRotate3 = BitRotate(14, -2) ; 14 = 1110b right-rotated twice -> 32771 (16 bits) = 1000 0000 0000 0011b

        ; Display the result.
        MsgBox($MB_SYSTEMMODAL, "", $iBitRotate3)

        ; Assign a Local variable the bitwise right-rotate operation of 14 on 32 bits.
        Local $iBitRotate4 = BitRotate(14, -2, "D")
        ; 14 = 1110b right-rotated twice -> -2147483645 (32 bits) = 1000 0000 0000 0000 0000 0000 0000 0011b (the first bit is signed)

        ; Display the result.
        MsgBox($MB_SYSTEMMODAL, "", $iBitRotate4)
    EndFunc   ;==>Example