Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator <<=

Multiplies a stored integer by a power of two through a left shift and updates the target.

Version: Python 3.14; repository image, production runtime not attested

Syntax

target <<= value

Multiplies a stored integer by a power of two through a left shift and updates the target.

Scale an integer in place at the level of the variable by a power of two. A shift count of zero leaves its numeric value unchanged.

Built-in integers grow as needed and do not drop high bits at a machine-word boundary. A negative count raises a value error before the variable is rebound.

A left shift multiplies a signed integer by a power of two.

Syntax

target <<= value

__ilshift__, __lshift__, __rlshift__ · ValueError

Worked example

n = -3; n <<= 2
n → -12

Examples

value = -3
value <<= 2
print(value)
print(bin(value))

Result

-12
-0b1100

A left shift multiplies a signed integer by a power of two.

Sources