Function Bitwise Class

RotateLeft

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

Signature (Visual Basic / VBA)

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

Code Example

    RotateLeft( 32, 2) = 128
    RotateLeft(-32, 2) = -125
    RotateLeft(255, 2) = 1020
    RotateLeft(Chr$(16) + Chr$(32), 2) = Chr$(64) + Chr$(128)

Parameters

Parameter Description
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 left. 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 right instead of to the left. 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.

Notes & Version History

Summary In the Rotate Left operation, the bits of the string are shifted to the left (less-significant-bits are shifted to more-significant-positions). Those bits which were occupying the vNBits most-significant-positions become the new least-significant-bits.