Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

>>= Operator

Performs an arithmetic right shift on the value of a variable and assigns the result back to the variable.

variable >>= amount

Parts

variable
Required. Variable of data type Byte, Short, Integer, or Long.
amount
Required. Numeric expression of a data type that widens to Integer.

Remarks

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 right shift, the bits shifted beyond the rightmost bit position are discarded, and the leftmost bit is propagated into the bit positions vacated at the left. This means that if variable has a negative value, the vacated positions are set to one. If variable is positive, or if its data type is Byte, the vacated positions are set to zero.

Example

The following example uses the >>= operator to shift the bit pattern of an Integer variable right by the specified amount and assign the result to the variable.

Dim Var As Integer = 10   ' Variable containing bit pattern to shift.
Dim Shift As Integer = 2   ' Amount to shift bit pattern.
Var >>= Shift   ' The value of Var is now 2 (bit lost off right end).

See Also

>> Operator | Assignment Operators | Bit Shift Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Assignment Statements

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.