Python-Ref > Data structures > Bit operations > Bit shift operations
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Bit shift operations

Expand/Shrink
Zdroj: (bits1-1.py)
  1   # 10 = 1010, 5 = 101
  2   print 10 >> 1
  3   
  4   # 16 = 10000, 2 = 10 
  5   print 16 >> 3
  6   
  7   # 3 = 11, 24 = 11000
  8   print 3 << 3
stdout:
5
2
24
Doba běhu: 23.9 ms
Expand/Shrink
Zdroj: (bits1-2.py)
  1   print 10 >> 1 == 10//2
  2   print 5*8 == 5 << 3
  3   print 100/8 == 100 >> 3
stdout:
True
True
True
Doba běhu: 20.6 ms