Shifts the bits of a numeric expression to the right
Syntax
Usage
result = lhs Shr rhs
Parameters
lhs
The left-hand side expression.
rhs
The right-hand side shift expression.
Return Value
Returns the result of lhs being shifted right rhs number of times.
Description
Operator Shr (Shift right) shifts all of the bits in the left-hand side expression (lhs) right a number of times specified by the right-hand side expression (rhs). This has the effect of dividing lhs by two for each shift. For example, &b0101 Shr 1 returns the binary number &b010, and 5 Shr 1 and returns 2.
If the left-hand side expression is signed, the sign bit is copied in the newly created bits on the left after the shift.
Neither of the operands are modified in any way.
This operator can be overloaded for user-defined types.
Example
'Half a number
Dim i As Integer
For i = 1 To 10
Print 1000 Shr i
Next i
Sleep
Output:
500
250
125
62
31
15
7
3
1
0
Dialect Differences
- Not available in the -lang qb dialect unless referenced with the alias __Shr.
Differences from QB
See also