The number system we use in computers is a positional number system. The positional number represents a number as a series of digits where the value of each digit depends on its position in the number. The positional number is referred to as a weighted number system as each digit is related to a certain weight.
In this section, we will study only those number systems under positional number systems which are used by the computer i.e., decimal number system, binary number system, hexadecimal, and octal number system.
Content: Number System in Computer
What is Positional Number System?
In a positional number system, the numbers are organized in the ordered set of digits where the value of each digit is decided by its position in the number and the base of the number system we are using.
In a positional number system, the value of each digit present in the number can be determined using the following three factors.
- The digit of which value we want to determine.
- The position of the digit in the number.
- The base or radix of the number system we are using.
The general form of any number in a positional number system is:
(…………….a3 a2 a1 a0. a–1 a–2 a–3……………)r
Here, the ai is a digit in the number, the value of ‘i‘ represents the position of the digit in the number, and r represents the radix or base of the number system it is using to represent the number.
The dot present between the digit a0 and a–1 is the radix point and value of the number can determine by:
.…. +a3 r3 + a2 r2 + a1 r1 + a0 r0+ a–1 r-1 + a–2 r-2 + a–3 r-3 +…..
X = Σi ( ai x ri)
In the section, ahead we will discuss the four most common number systems under the positional number system.
Decimal Number System
The decimal number system is the number system that we use in our daily life routine to count and calculate certain things. There are 10 digits that we use to represent a decimal number from 0 to 9 (i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
The base or the radix of the decimal number is 10. Let us see how do we express the decimal number 8246.
(8246)10 = (8 x 1000) + (2 x 100) + (4 x 10) + (6×1)
= (8 x 103) + (2x 102) + (4 x 101) + (6 x 100)
As here, in decimal number system we have the radix 10 each digit present in the is multiplied by 10, and the power of 10 is decided by the position of the corresponding digit in the number.
For example, we count the position of the digits in the number 8246 then the digit 6 is at one’s place, 4 is at ten’s place, 2 is at hundred’s place and 8 is at thousand’s place.
The fractional number in the decimal system also follows the same principle the only change is that the power of 10 is negative. Consider then fractional number 0.264
(0.264)10 = (2 x 10-1) + (6 x 10-2) + (4 x 10-3)
The digit at the extreme left side of a number is referred to as the most significant bit. And the digit at the extreme right side of a number is referred to as the least significant bit.
In general terms the representation of decimal number is:
X = {……….d4d3d2d1d0d-1d-2d-3…….}10
= {…. + d3 103 + d2 102 + d1 101 + d0 100+ d–1 10-1 + d–2 10-2 + d–3 10-3 +….}10
X = Σi ( di x 10i)
If you can observe the representation of decimal numbers then see that weight of each position is 10 times the value of the position to its right and it is one-tenth the value of the position to its left.
Binary Number System
In the binary number system, any number is represented using two bits or two digits that are 0 and 1. As the binary number system uses two bits to represent the number the radix or base in the binary system is 2.
Now let us see how can we represent a binary number to a decimal. Consider the binary number 1011012. Here the subscript 2 is used to avoid confusion between the various number system.
In fact, the subscript 10 is used to represent the decimal number, subscript H or16 is used to represent hexadecimal numbers and subscript 8 is used to represent octal numbers. So, let’s start with the binary number 1011012.
1011012 = (1 x 25) + (0x 24) + (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= 32 + 0 + 8 + 4 + 0 + 1
1011012 = 4510
Like in decimal, the fractional number in binary system are represented with the negative power of 2. For example, consider the binary fractional number:
101.1102 = (1 x 22) + (0 x 21) + (1 x 20) + (1 x 2-1) + (1 x 2-2) + (0 x 2-3)
= 4 + 0 + 1 + 0.5 + 0.25 +0
= 5.75
The binary representation of a number is:
X = {……….b4b3b2b1b0b-1b-2b-3…….}2
= {…. + b3 23 + b2 22 + b1 21 + b0 20+ b–1 2-1 + b–2 2-2 + b–3 2-3 +….}2
X = Σi ( bi x 2i)
Hexadecimal System
Although the binary number is more convenient for the computer still it is not convenient for human beings. Hence, we need a compact method to represent numbers. Though the decimal number can resolve the need for a compact number system it becomes tedious to convert binary to decimal and vise versa. This is why the hexadecimal number system came into use.
As we know the decimal number uses 10 digits (0-9) to represent a number and to represent these 10 digits we require 4 binary bits. But the problem is the 4 binary bits represent 16 combinations of which for only 10 combinations we have a decimal representation but what about the remaining 6 combinations.
So, for that, we use a hexadecimal form. You can understand this with the help of the table below:
Now you can understand how the hexadecimal number represents a compact form.
To understand the ease of this system let us see how a long string of binary bits 1010100111112 is easy converted to the hexadecimal form:
Note: To convert a binary number into a hexadecimal form the first group all binary bits into sets of four bits which is also referred to as a nibble.
1010 1001 1111
Now as we have divided the string of binary bits into three sets each having four bits. Find the corresponding symbol for each set from the table above which would be:
A9F16
Converting this binary string into decimal would be tedious work but converting the long string of binary bits in hexadecimal number is faster and easier. And the hexadecimal number is even more compact than a binary number.
Now let us see how can this hexadecimal number can be converted into a decimal numbers.
A9F16 = (A16 x 162) + (916 x 161) + (F16 x 160)
= (1010 x 162) + (910 x 161) + (1510 X 160)
= (10 x 256) + (9 x 16) + (15 X 1)
= (2560) + (144) + (15)
Octal System
The octal number was used frequently in the past. It uses 8 digits from 0 to 7 (0, 1, 2, 3, 4, 5, 6, 7). The radix of octal number is 8 and the general form to represent the octal number is:
X = {……….o4 o 3 o 2 o 1 o 0 o -1 o -2 o -3…….}8
= {…. + o 3 83 + o 2 82 + o 1 81 + o 0 80+ o –1 8-1 + o –2 8-2 + o –3 8-3 +….}8
X = Σi ( o i x 8i)8
Consider a octal number 4678 and we will convert this to decimal.
4678 = (4 x 82) + (6 x 81) + (7 x 80)
= (256) + (48) + (7)
= 31110
So, these are the positional number system that is used while working with the computer. Among all of these, the hexadecimal number presents compact numbers and provides easier conversions.
Leave a Reply