Erle Robotics Learning Python GitBook Free

Bitwise operators basics

Bitwise operations might seem a little esoteric and tricky at first, but you'll get the hang of them pretty quickly.

Bitwise operations are operations that directly manipulate bits. In all computers, numbers are represented with bits, a series of zeros and ones. In fact, pretty much everything in a computer is represented by bits. This course will introduce you to the basic bitwise operations and then show you what you can do with them.

Here is a list with one of the most used bitwise operators. We will explain them and exercise them later on.

Bitwise operator Name Execution
print 5 >> 4 Right Shift 0
print 5 << 1 Left Shift 10
print 8 & 5 Bitwise AND 0
print 9 pipe 4 Bitwise OR 13
print 12 ^ 42 Bitwise XOR 38
print ~88 Bitwise NOT -9