Understanding Number Systems: Decimal, Binary, Octal, and Hexadecimal
Hey Friends, Today We're talking about number systems in computers, Numbers play a fundamental role in our everyday lives, from basic calculations to complex algorithms used in different computing areas like machine learning, artificial intelligence, robotics etc, etc. As we all know a computer is used to process data entered by the users and provide results as output. In this tutorial, we'll explore the concept of the number system, different types of number systems, number system conversion like binary to decimal conversion, decimal number conversion, octal to decimal conversion, hexadecimal to decimal conversion with examples, please focus on the examples so that you can understand easily.
What is a Number System?
A set of rules used to represent numbers is know as Number System. It provides a standardized way of expressing and calculating values. A set of instructions has to be fed into the computer system to instruct the computer how to process data. And which type of calculation is done when users enter some information through input devices. All this information is instructed in the form number system that the computer can understand. This Data can be in the form of characters (a,b,c,d) or numbers (0,1,2,3, .... 9). The number system revolves around a base, which shows how numbers are represented. For example, the decimal number system is a base-10 system, which means it uses ten symbols (0-9) to represent values.
Types of Number System
There are Mainly 4 (four) types of a number system. These are:-
- Decimal Number System (Base-10)
- Binary Number System (Base-2)
- Octal Number System (Base-8)
- Hexadecimal Number System (Base-16)
Note:- The number of digits that can occur at each position of a number in any number system is known as the base of that number system.
Now, we are going to discuss this briefly.
1. Decimal Number System (Base-10)
This is the most commonly used number system in our daily life. The number of digits in number system are like :- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
The base of that number is 10. The decimal number system is a positional number system which means each digit has a fixed position or weight associated with it, that is why it is also known as the weighted number system.
For Example:-
Let some number randomly, we assume a number 786, now in that number the weight of number [6] is 1 (ones), number [8] is 10 (tens), and number [7] is 100 (hundred). The Number of tens increases every time whenever the number increases.
7 × (10 ^ 2) = 7 × 100 = 700
8 × (10 ^ 1) = 8 × 10 = 80
6 × (10 ^ 0) = 6 × 1 = 6
Sum of all number are : 700 + 80 + 6 = 786
- Each digit has a placed value like (ones, tens, hundreds...and so on.)
- Each placed values is a power of 10 (10 ^ 0 = 1, 10 ^ 1 = 10, 10 ^ 2 = 100, etc.)
Ex:- 4555 In this example, 4 is the most significant number as the base value of 4 was thousand means 10^4.
We can represent them like (10 ^ 0) for 6, (10 ^ 1) for 8, and (10 ^ 2) for 7. That’s why we read it as Seven Hundred Eighty-Six.
As we know that, in the decimal number system, the base is 10, so we represent the given number as 786 ^ 10 (786).
2. Binary Number System (Base-2)
The binary number system is widely used in computers and digital electronic devices. It uses two digits : 0 and 1. In the Binary Number System, each digit is known as a "bit". The Base of the binary number is 2. In Computer, the Binary Number is used to process data and store data.
Let's See an example of binary number system
Ex: Suppose you have a binary number that you want to convert into decimal. Let's take a binary number 1101 now we're going to convert it into a decimal number.
Steps to convert Binary to decimal
1 × (2 ^ 3) = 1 × 8 = 8
0 × (2 ^ 2) = 0 × 4 = 0
1 × (2 ^ 1) = 1 × 2 = 2
1 × (2 ^ 0) = 1 × 1 = 1
Adding up these values, we get: 8 + 0 + 2 + 1 = 11
So, the decimal conversion output of the binary number 1011 is 11.
3. Octal Number System (Base-8)
The octal number system uses eight (8) digits: 0, 1, 2, 3, 4, 5, 6, 7. It is often used in computing, particularly as a shorthand for binary numbers because one octal digit corresponds to three binary digits. The base of the octal number is 8. Don't confuse octal and decimal number systems each has a different base value and the number of digits used.
Let's Convert an Octal Number into Decimal to understand better.
Ex: Let an Octal Number: 127
Now Let's see the conversion of an octal number into a decimal value.
Steps to convert Octal to decimal
1 x (8 ^ 2) = 1 x 64 = 64
2 x (8 ^ 1) = 2 x 8 = 16
7 x (8 ^ 0) = 7 x 1 = 7
Total: 64 + 16 + 7 = 87 (in decimal)
In the octal number system:
- Each digit has a placed value (ones, eights, sixty-fours, etc.)
- Each placed value is a power of 8 (8^0 = 1, 8^1 = 8, 8^2 = 64, etc.)
4. Hexadecimal Number System (Base-16)
Hexadecimal Numbers are usually used in computer programming and digital electronics. It is also used in web development to represent color codes. The hexadecimal number system uses 16 digits which are (0-9) and (A-F) for 10-15. It is often used in computing to represent large binary numbers. The hexadecimal number base is 16.
Let's Convert a Hexadecimal Number into a Decimal to understand better way.
Ex: Let a Hexadecimal color code Number: EB4034 (#EB4034 : it is a color code which provides red color).
Now Let's see the conversion of a Hexadecimal number into a decimal value.
Steps to convert Hexadecimal to decimal
E × (16 ^ 5) = 14 × 1048576 = 14680064
B × (16 ^ 4) = 11 × 65536 = 720896
4 × (16 ^ 3) = 4 × 4096 = 16384
0 × (16 ^ 2) = 0 × 256 = 0
3 × (16 ^ 1) = 3 × 16 = 48
4 × (16 ^ 0) = 4 × 1 = 4
Total: 14680064 + 720896 + 16384 + 0 + 48 + 4 = 15417396
In the Hexadecimal number system:
- Each placed value has a power of 16.
- Hexadecimal Digits are (0-9) and (A-F)
In this tutorial, we covered the basic things of all the number systems we will describe all the number systems separately in our future blogs. In Separate blogs, you can cover how to covert any number system to another number system like decimal to hexadecimal, decimal to octal, octal to decimal, hexadecimal to octal, binary to octal, binary to decimal, binary to hexadecimal, and so on.. so stay tune with us for more in future.