Arithmetic shifts are not circular, which means the bits shifted off one end of the result are not reintroduced at the other end. In an arithmetic left shift, the bits shifted beyond the range of the result data type are discarded, and the bit positions vacated on the right are set to zero.

To prevent a shift by more bits than the result can hold, Visual Basic masks the value of amount with a size mask that corresponds to the data type of pattern. The binary AND of these values is used for the shift amount. The size masks are as follows:

Data type of pattern

Size mask (decimal)

Size mask (hexadecimal)

SByte, Byte

7

&H00000007

Short, UShort

15

&H0000000F

Integer, UInteger

31

&H0000001F

Long, ULong

63

&H0000003F

If amount is zero, the value of result is identical to the value of pattern. If amount is negative, it is taken as an unsigned value and masked with the appropriate size mask.

Arithmetic shifts never generate overflow exceptions.

Note:

The << operator can be overloaded, which means that a class or structure can redefine its behavior when an operand has the type of that class or structure. If your code uses this operator on such a class or structure, be sure that you understand its redefined behavior. For more information, see Operator Procedures.