The Numbering Systems

There are five different numbering systems used in computer programming; Decimal, Hexadecimal, Octal, Binary, and Base64.
Yes! Base64 is a numbering system, it’s not encryption! Ok, well, it is more of an encoding system, and never really used as a numbering system, but the concept is the same.

Obviously, as we already know, at the machine level, computers only use the binary number system. All the other numbering systems are just used to improve human-readability of that binary data, Base64 being an exception, but more on that later.

Before we look into the different numbering systems, let’s first try to understand what exactly a numbering system means. And because we are already familiar with the Decimal Numbering System, let’s use it as our reference to lay down the concepts.


The Decimal Numbering System :

The decimal numbering system, which is also called as the Base 10 numbering system, uses the symbols from 0 to 9 to represent numbers.
Yes, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9… are not actually digits or numbers, these are just numerals or symbols or shapes that represent those numbers.

So, let’s see.

0
1 - ⭐
2 - ⭐⭐
3 - ⭐⭐⭐
4 - ⭐⭐⭐⭐
5 - ⭐⭐⭐⭐⭐
6 - ⭐⭐⭐⭐⭐⭐
7 - ⭐⭐⭐⭐⭐⭐⭐
8 - ⭐⭐⭐⭐⭐⭐⭐⭐
9 - ⭐⭐⭐⭐⭐⭐⭐⭐⭐

Here we are incrementing the numbers from 0 to 9 for counting items from, well, 0 to 9. But, what if we want to count more than 9 items?

Simple, reset the number back to.zero and place 1 to the left of it, and then again start incrementing the right value.

10, 11, 12... etc.

By placing a new number to the left we are shifting to the next 10s place-value.

So, now we have numbers from 0 to 19. What about more? Again reset the right number back to zero and increment the left number by one.

And, we now have numbers from 0 until 29. We can go on doing this till we reach 99, after which we will have to reset both the numbers to zero and place a new digit to the left, essentially shifting to the next 10s place-value which is 10 x 10 = 100, and we now have a 100.

And we can go on for ever…

The place-value chart in the Base-10 numbering system can be represented as below.

10^p…….10^410^310^210^110^0
ps…….10000s1000s100s10s1s

Notice the sequence, each place-value is 10 times higher than the one before it.

10^0 = 1
10^1 = 10 x 1 = 10^0 x 10
10^2 = 10 x 10 X 1 = 10^1 x 10
10^3 = 10 x 10 x 10 x 1 = 10^2 x 10
... and so on

So a number 7253 can be broken down as

7 x 1000	+ 2 x 100	+ 5 x 10 	+ 3 x 1
7 Thousands 	+ 2 Hundreds 	+ 5 Tens	+ 3 Ones

Let’s try to generify our above findings so that we can apply them to numbering systems with any Base value

Place-value p in a numbering system with a Base b can be defined by b^p
B^p…..B^4B^3B^2B^1B^0

Great! Now that we understand what a numbering system is, let’s look into the Binary Numbering System…


The Binary Numbering System :

The binary numbering system, as the name suggests, uses only two symbols 0 and 1 to represent numbers. This makes it a Base 2 numbering system,

Let’s apply our understanding of numbering systems to the above definition.
This is our generic place-value chart.

B^p…..B^4B^3B^2B^1B^0

Let’s create the place-value chart for  Binary Numbering System using our generic definition. For Binary B = 2

2^p…….2^42^32^22^12^0
ps…….16s8s4s2s1s

In the rightmost position, we again have the 1s, but in the following positions, we now have multiples of 2 –   2s, 4s, 8s, 16s, and so on…

So, how do we count? Exactly the same way we did for Decimal, just that we now shift the position every 2  increments. That’s what Base 2 means.

  0 - 
1 - ⭐
10 - ⭐⭐
11 - ⭐⭐⭐
100 - ⭐⭐⭐⭐
101 - ⭐⭐⭐⭐⭐
110 - ⭐⭐⭐⭐⭐⭐
111 - ⭐⭐⭐⭐⭐⭐⭐
...

A binary number 100110 can be interpreted as

Binary number : 100110

32s 16s 8s 4s 2s 1s
1 0 0 1 1 0

= 1x32s + 0x16s + 0x8s + 1x4s + 1x2s + 0x1s
= 32 + 0 + 0 + 4 + 2 + 0
= 38

Let’s take one more example

Binary number : 111001

32s 16s 8s 4s 2s 1s
1 1 1 0 0 1

= 1x32s + 1x16s + 1x8s + 0x4s + 0x2s + 1x1s
= 32 + 16 + 8 + 0 + 0 + 1
= 57

Easy as pie!

As we are already feeling high, let’s go on and kill the Octal and Hexadecimal numbering systems as well. It should now be a piece of cake.


The Octal Numbering System :

The Octal Numbering System, again, as the name suggests, uses 8 symbols to represent numbers. This makes it a Base-8 numbering system

Now, as we already know how to do it, let’s jump right in!

This is our generic place-value chart

B^p…..B^4B^3B^2B^1B^0

This is a place-value chart for Base-8

8^p…….8^48^38^28^18^0
ps…….4096s512s64s8s1s

Now let’s count

0
1  - ⭐
2  - ⭐⭐
3  - ⭐⭐⭐
4  - ⭐⭐⭐⭐
5  - ⭐⭐⭐⭐⭐
6  - ⭐⭐⭐⭐⭐⭐
7  - ⭐⭐⭐⭐⭐⭐⭐
10 - ⭐⭐⭐⭐⭐⭐⭐⭐
11 - ⭐⭐⭐⭐⭐⭐⭐⭐⭐

Um? 7 and then 10?
Of course, It’s Base-8, remember?
We can increment only from 0 until 7, after that we should move to the next place-value.

Think about it…

We are not changing the way we count, we are just changing the way we represent numbers.

Let’s interpret an octal number then, shall we?

Octal number : 127

64s 8s 1s
1 2 7

= 1x64s + 2x8s + 7x1s
= 64 + 16 + 7
= 87

One more? Of course! We now know how to interpret numbers!

Octal number : 1570

512s 64s 8s 1s
1 5 7 0

= 1x512s + 5x64s + 7x8s + 0x1s
= 512 + 320 + 56 + 0
= 888

Bring on Hexadecimal! We’re now ready for you!


The Hexadecimal Numbering System :

In the hexadecimal, we have 16 symbols to represent a number. This makes it a Base-16 numbering system.

Till now we have seen the Decimal system which uses symbols from 0 to 9, and binary which 0 and 1, and Octal which uses 0 to 7. But how can we represent 16 symbols?

Easy! Use 0 to 9 for the first 10 and A to F for the remaining 6, these are just representations after all. They could have chosen any symbols, but for brevity, the first letters of the alphabet was a perfect choice.

So, now we have

0
1 - ⭐
2 - ⭐⭐
3 - ⭐⭐⭐
4 - ⭐⭐⭐⭐
5 - ⭐⭐⭐⭐⭐
6 - ⭐⭐⭐⭐⭐⭐
7 - ⭐⭐⭐⭐⭐⭐⭐
8 - ⭐⭐⭐⭐⭐⭐⭐⭐
9 - ⭐⭐⭐⭐⭐⭐⭐⭐⭐
A - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
B - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
C - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
D - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
E - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
F - ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐

Let’s create the place-value chart

This is our generic chart

B^p…..B^4B^3B^2B^1B^0

This will be the chart for Base-16

8^p…….16^416^316^216^116^0
ps…….65536s4096s256s16s1s

Let’s interpret some hexadecimal numbers

Hexadecimal number : 1F4

256s 16s 1s
1 F 4

= 1x256s + Fx16s + 4x1s
= 256 + 240 + 4
= 500

Hexadecimal number : F1A7

4096s 256s 16s 1s
F 1 A 7

= Fx4096 + 1x256s + Ax16s + 7x1s
= 61440 + 256 + 160 + 7
= 61863

YAY! That’s awesome!

So, what about Base-64? Let’s check it out as well


Base64 Encoding System :

By now, it should be very obvious that Base-64 means, the numbers are represented using 64 symbols. And, looking into Hexadecimals, it would also be pretty easy to guess that Alphabets would be judiciously used, and you would be right!

The Base64 encoding system uses numerals 0 to 9, uppercase alphabets A to Z, and also lowercase alphabets a to z.

So, till now we have…
10 numerals + 26 uppercase letters + 26 lowercase letters
That gives us a total of 62 symbols.
But we are still short of 2 symbols, so for the remaining two + and / symbols are used.
In conclusion,

Base64 uses 0 to 9A to Z, a to z and + and /

Everything else with Base64 is exactly similar to the other numbering systems, so I won’t go into interpreting it.

But, it is worth mentioning here that Base64 is not used for legibility, but rather for encoding large bytes of data into a short alphanumeric string.


So, Why did the computer engineer get X-mas and Halloween mixed up?
Because, Oct(31) == Dec(25)