CKTIS / Python
Operator <<
Shifts all integer bits left by the count on the right.
Version: Python 3.14; repository image, production runtime not attested
Syntax
left << rightShifts all integer bits left by the count on the right.
A shift inserts zero bits at the right of an integer. Python integers have no fixed arithmetic width, so high bits are retained as the magnitude grows.
The right operand counts bit positions and must be a nonnegative integer for the built-in operation. Zero leaves the operand unchanged; a negative count raises a value error.
For a nonnegative count this multiplies a signed integer by the corresponding power of two.
Syntax
left << right
__lshift__, __rlshift__ · ValueError
Worked example
3 << 2 → 12
3 << 0 → 3
3 << -1 → ValueError
(1 << 80).bit_length() → 81
Examples
print(3 << 4)
print(-3 << 1)
Result
48 -6
For a nonnegative count this multiplies a signed integer by the corresponding power of two.