Operators
>> — Right bit shift
For integers, shifts toward lower bit positions. For nonnegative count it equals floor division by 2**count, including negative inputs, so -3 >> 1 is -2 rather than -1. Python integers behave as if sign bits extend indefinitely. There is no separate unsigned right-shift operator. Negative counts raise ValueError. Custom implementations use __rshift__ and __rrshift__.
Formal Syntax & Structure
python syntaxpython
left >> rightParameters & Attributes
| Name | Type | Description |
|---|---|---|
| left | int or supporting object | Integer to shift or supporting object. |
| right | int or supporting object | Nonnegative integer bit count for integer shifting. |
Return Value
object
Result selected by the operand types and their operation implementations.
Working Example
Example Snippetpython
print(20 >> 2)print(-3 >> 1)print(1 >> 100)