Name

<< (left shift)

Examples
m = 1 << 3  # In binary: 1 to 1000
print(m)  # Prints "8"
n = 1 << 8  # In binary: 1 to 100000000
print(n)  # Prints "256"
o = 2 << 3  # In binary: 10 to 10000
print(o)  # Prints "16"
p = 13 << 1 # In binary: 1101 to 11010
print(p)  # Prints "26"
# Packs four 8 bit numbers into one 32 bit number
a = 255     # Binary: 00000000000000000000000011111111
r = 204     # Binary: 00000000000000000000000011001100
g = 204     # Binary: 00000000000000000000000011001100
b = 51      # Binary: 00000000000000000000000000110011
a = a << 24 # Binary: 11111111000000000000000000000000
r = r << 16 # Binary: 00000000110011000000000000000000
g = g << 8  # Binary: 00000000000000001100110000000000
# Equivalent to "color argb = color(r, g, b, a)" but faster
argb = a | r | g | b
fill(argb)
rect(30, 20, 55, 55)
Description
Syntax
value << n
Parameters
value
n
Related >> (right shift)
Updated on Wed Jan 18 17:32:21 2017.
Creative Commons License