# Number Systems — Decimal, Binary, Octal and Hexadecimal

Image Courtesy : Pexels

Let?s explore few different number systems that are in use today and see how with simple three rules, we can build any number system we want.

In mathematics, a ?base? or a ?radix? is the number of different digits or combination of digits and letters that a system of counting uses to represent numbers. ~Wiki~

For example,

• Base 10 (Decimal) ? Represent any number using 10 digits [0?9]
• Base 2 (Binary) ? Represent any number using 2 digits [0?1]
• Base 8 (Octal) ? Represent any number using 8 digits [0?7]
• Base 16(Hexadecimal) ? Represent any number using 10 digits and 6 characters [0?9, A, B, C, D, E, F]

In any of the number systems mentioned above, zero is very important as a place-holding value. Take the number 1005. How do we write that number so that we know that there are no tens and hundreds in the number? We can?t write it as 15 because that?s a different number and how do we write a million (1,000,000) or a billion (1,000,000,000) without zeros? Do you realize it?s significance?

First, we will see how the decimal number system is been built, and then we will use the same rules on the other number systems as well.

## So how do we build a number system?

We all know how to write numbers up to 9, don?t we? What then? Well, it?s simple really. When you have used up all of your symbols, what you do is,

• you add another digit to the left and make the right digit 0.
• Then again go up to until you finish up all your symbols on the right side and when you hit the last symbol increase the digit on the left by 1.
• When you used up all the symbols on both the right and left digit, then make both of them 0 and add another 1 to the left and it goes on and on like that.

If you use the above 3 rules on a decimal system,

• Write numbers 0?9.
• Once you reach 9, make rightmost digit 0 and add 1 to the left which means 10.
• Then on right digit, we go up until 9 and when we reach 19 we use 0 on the right digit and add 1 to the left, so we get 20.
• Likewise, when we reach 99, we use 0s in both of these digits? places and add 1 to the left which gives us 100.

So you see when we have ten different symbols, when we add digits to the left side of a number, each position is going to worth 10 times more than it?s previous one.

Let?s take the same decimal number system. There are only two rules actually.

• You have a symbol to represent a quantity [0?9]
• Then the meaning of a digit based on its position ? let?s get this clarified a bit.

Let?s take one digit number ?8?. This simply means 8, in other words, it is exactly what it says it represents. What about 24? In case of two digits, right digit says what it means, but left digit means ten times what it says. That is, 4 is 4, 2 is 20. Altogether forms 24.

If we take a three digit number, rightmost digit means what it says, the middle one is ten times what it says, leftmost digit 100 times what it says. Simply if we take number 546, it means 6 + (10 * 4) + (5 * 100) = 546.

## Binary

With binary, we have only two digits to represent a number, 0 and 1 and we are already out of symbols. So what do we do? Let?s apply the same rules that we used on the decimal system.

We make the right digit 0 and add 1 to left, that is, our next number is ?10?. Then we go up until we used up all our symbols on the right side.So the next number in line is 11.

After ?11?, we put 0s in both these places and add 1 to the left and we get 100.

Then 101, 110, 111 then 1000 ?

This binary number system is based on two digits and each position is worth two times more than the previous position.

Reading a binary number is almost same as reading a decimal. Right digit says what it means, next one means two times the previous one, after that 4 times etc?

So 101 means 5 in decimal.

These same rules apply to octal and hexadecimal number systems as well. With octal, we have only 8 digits to represent numbers so once we get to 7 the next number is 10 and in hexadecimal, we have 10 digits and 6 letters to represent numbers. In that case, when we reach 9 next number is represented in the letter ?A?. Next one ?B?. Likewise, we go up to letter ?F? and after ?F? comes ?10?.

I?ll just list down few numbers in these 4 different number systems and see whether you can apply the rules that we discussed above to get the next number.

To understand how computers represent positive and negative numbers, please read this and more on hexadecimal can be found here.

References

• http://www.buthowdoitknow.com/