Menu
Coddy logo textTech

What is bit manipulation?

Lesson 1 of 17 in Coddy's Bit Manipulation course.

Before we get into what bit manipulation is, let's first talk about the basics of the place it arises from i.e. representation of numbers.

How are numbers represented?

Let's understand with an example.

Base 10

Our traditional number system (0, 1, 2, 3, 4, ... 9) are represented with the Base 10 Format.

The number 345 can be written as an equation: 10<sup>2</sup>*3 + 10<sup>1</sup>*4 + 10<sup>0</sup>*5, or in words: 3 times 10 to the second, 4 times 10 to the first, and 5 times 10 to the 0. So, here base 10 basically means that we can use digits from 0-9 to represent a number. 

 

 

Similarly, we have base 2 which is what computers use. In base 2 we can do the exact same thing.

When we store a number in the computer, it is stored as a series of 0's and 1's, in the form of bit. Bit is either 0 or 1 which is the smallest unit of data, a computer is capable of understanding.

So, bit manipulation can thus be defined as an act of algorithmically manipulating bits or other pieces of data using bit-level operators to achieve required results. 

Try it yourself

This lesson doesn't include a code challenge.

All lessons in Bit Manipulation