# Bitcode Manipulation basics

## What is bit manipulation?

Bit manipulation is the act of algorithmically manipulating bits or other pieces of data shorter than a word. Computer programming tasks that require bit manipulation include low-level device control, error detection and correction algorithms, data compression, encryption algorithms, and optimization.

### bitwise NOT operator

the *bitwise NOT operator* (~) inverts all bits in a number.

The NOT operator basically helps you find the “opposite” value by inverting all the bits

### bitwise AND operator

the *bitwise AND operator* (&) combines the bits of two numbers and returns a new number whose bits are set to 1 only if the bits were equal to 1 in *both* input numbers

### bitwise OR operator

the bitwise OR operator ( |
) compares the bits of two numbers. The operator returns a new number whose bits are set to 1 if the bits are equal to 1 in either input number. |

### bitwise XOR operator

the *bitwise XOR operator* , or “exclusive OR operator” (^), compares the bits of two numbers. The operator returns a new number whose bits are set to 1 where the input bits are different and are set to 0 where the input bits are the same.