<-- Previous || Up || Next -->

Rotate Right Function
Bitwise Class

Public Function RotateRight( _
      ByVal vValue As Variant _
    , ByVal vNBits As Variant _
    ) As Variant

Rotate the bits to the right within any type of value, moving those bits in the least-significant-positions to the most-significant-positions.

Examples:
    RotateRight( 32, 2) = 8
    RotateRight(-32, 2) = 16376
    RotateRight(255, 2) = -16321
    RotateRight(Chr$(16) + Chr$(32), 2) = Chr$(4) + Chr$(8)
In the Rotate Right operation, the bits of the string are shifted to the right (more-significant-bits are shifted to less-significant positions). Those bits which were occupying the vNBits least-significant-positions become the new most-significant-bits.
See also:
    ShiftRight Function
    ArithmeticShiftRight Function
    RotateLeft Function
vValue: Value whose bits are to be rotated left. Function returns Null if vValue is Null.

vNBits: The number of positions that the bits within vValue are to be rotated right. Function returns Null if vNBits is Null or cannot be fixed up to a number.

Function returns vValue unchanged if vNBits is 0 (zero).

If vNBits is < 0 (less than zero), then the function will rotate bits to the left instead of to the right.

Function will return the same type of value as vValue, or in the case of Date values (in which not all combinations of bits are valid) it may possibly generate a runtime error.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.