Skip to content

The Binary Number System

New Course Coming Soon:

Get Really Good at Git

Introduction to the Binary Number System

I recently introduced the Decimal Number System, the one we are used as humans.

As I said in that post, as humans we commonly have 10 fingers and we can count up to 10, hence the popularity of that system in our history.

The Binary Number System is the second most important system for our species, as it led the electronics and computer revolution.

In electronics, we have 2 states: 0 or 1. There’s 0 volts, or there’s 5 (or 9, 12, whatever). A gate is open, or it’s closed.

It’s either one or the another.

The digit in the binary number system is called bit.

As the decimal number system, also the binary number system is positional.

We sum each digit in the binary number system mutiplied by the power of 2 depending on their position, starting at position 0 from the right.

Given that:

\[2^0\] equals to 1


\[2^1\] equals to 2


\[2^2\] equals to 4


\[2^3\] equals to 8, and so on..



We can represent numbers using a series of bits:

1 can be represented as \[1\times2^0\]



10 can be represented as \[1\times2^1 + 0\times2^0\]



111 can be represented as \[1\times2^2 + 1\times2^1 + 1\times2^0\]



Leading zeros in a number can be dropped, or added if needed, because they do not mean anything on the left of the top left 1: 110 can be represented a 0110 or 00000110 if needed. It holds the same exact meaning, because as the system above explained, we are simply multiplying a power of 2 times zero.

Using binary numbers we can represent any kind of number in the decimal number system.

We need to have an adequate number of digits to represent enough numbers. If we want to have 16 numbers, so we can count from 0 to 15, we need 4 digits (bits). With 5 bits we can count 32 numbers. 32 bits will give us 4,294,967,296 possible numbers.

64 bits will give us 9,223,372,036,854,775,807 possible numbers. It grows pretty quickly.

Here is a simple conversion table for the first 4 digits, which we can generate using just 2 bits:

Decimal numberBinary number
000
101
210
311

Here is a simple conversion table for the first 8 digits:

Decimal numberBinary number
0000
1001
2010
3011
4100
5101
6110
7111

If you notice, I repeated the above sequence, adding 1 instead of 0 in the series from 4 to 7.

Here is a simple conversion table for the first 16 digits:

Decimal numberBinary number
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001
101010
111011
121100
131101
141110
151111

Again, I repeated the sequence we used to get the first 8 numbers, prepended 0 to the first set 0-7 and prepended 1 to 8-15.

I’ll soon talk about performing operations like sum and division with binary numbers, the hexadecimal numbers system, how to convert from binary to decimal and to hexadecimal, without looking at tables like these, and vice versa.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!

Here is how can I help you: