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

Arithmetic Shift Right Function
Bitwise Class

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

Perform the arithmetic shift right (ASR) operation on any type of value.

Summary: In the Arithmetic Shift Right operation, the bits of the string are shifted to the right (more-significant-bits are shifted to less-significant positions). The least-significant-bits are lost, and the most-significant-bits take on the value of the bit that was previously most-significant (the "sign" bit, the most-significant-bit is used to fill-in each of the new bit positions opened up by the shift).
       ArithmeticShiftRight( 128, 2) = 32
       ArithmeticShiftRight(-128, 2) = -32
       ArithmeticShiftRight(Chr$(128)) = Chr$(224)
       ArithmeticShiftRight(Chr$(0) + Chr$(128)) = Chr$(0) + Chr$(32)
       ShiftRight( 128, 2) = 32
       ShiftRight(-128, 2) = 16352
       ShiftRight(Chr$(128)) = Chr$(32)
See also:
    ShiftRight Function
    RotateRight Function
vValue: Value whose bits are to be shifted right arithmetically. Function returns Null if vValue is Null.

vNBits: The number of positions that the bits within vValue are to be shifted 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).

Function returns Null if vNBits is < 0 (less than zero).

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.