In a computer system architecture, computer number systems are how we represent numbers.
Generally, there are two types of Number systems: the Positional & Non-positional Number systems.
What is positional number system?
Each symbol in a positional number system represents a different value. There is a fixed position for every digit of a number. A positional number’s total value is the sum of the resulting values of all positions.
For example > 12 can be written as 1 x 10 + 2 x 1, 10 + 2 = 12.
What is non- positional number system?
In a non-positional number system, each symbol, regardless of its position, represents the same value. There is no fixed position for every digit of a number. Hence, they can be kept anywhere in the number & the value will remain the same.
For example > in the Roman numeral system, I denotes one, II denotes two, and so on.
Types of positional number system
- Binary number system: The only digits in a Binary number are 0 and 1. In this number system, each number (value) is represented by 0 and 1. Since it only has two digits, the binary number system’s base is 2. e.g. (10010)_{2}
- Octal number system: Eight (8) digits from 0 to 7 are used in the octal number system. In this number system, each number (value) is represented by 0,1,2,3,4,5,6, and 7. Since it only has 8 digits, the octal number system’s base is 8. e.g. (32)_{8}
- Decimal number system: There are ten (10) digits in the decimal number system, ranging from 0 to 9. In this number system, each number (value) is represented by 0,1,2,3,4,5,6, 7,8, and 9. Since it only has 10 digits, the decimal number system’s base is 10. e.g. (192)_{10}
- Hexadecimal (hex) number system: There are sixteen (16) alphanumeric values in the Hexadecimal number system, ranging from 0 to 9 and A to F. Since it has 16 alphanumeric numbers, the hexadecimal number system’s base is 16. e.g. (C50)_{16}
Comparison of Decimal, Binary, Octal & Hexadecimal Number system.
Decimal | Binary | Octal | Hexadecimal |
---|---|---|---|
0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 |
2 | 10 | 2 | 2 |
3 | 11 | 3 | 3 |
4 | 100 | 4 | 4 |
5 | 101 | 5 | 5 |
6 | 110 | 6 | 6 |
7 | 111 | 7 | 7 |
8 | 1000 | 10 | 8 |
9 | 1001 | 11 | 9 |
10 | 1010 | 12 | A |
11 | 1011 | 13 | B |
12 | 1100 | 14 | C |
13 | 1101 | 15 | D |
14 | 1110 | 16 | E |
15 | 1111 | 17 | F |
16 | 10000 | 20 | 10 |
17 | 10001 | 21 | 11 |
18 | 10010 | 22 | 12 |
19 | 10011 | 23 | 13 |
20 | 10100 | 24 | 14 |
Number system Conversion
The need for number system conversion is very crucial in Computers or any digital devices. Different types of number systems can be used in electronic and digital systems (e.g. Decimal, Hexadecimal, Octal, Binary).
The number system, as we all know, is a way of communicating numbers. In number system conversion, we’ll look at how to change a number from one base to another.
Binary to Decimal Number System
The decimal number is equal to the sum of all binary digits (say, b_{n}) times their power of 2 (2^{n}). For the integer part, the positions are from right to left are as 2^{0}, 2^{1}, 2^{2}, 2^{3}… and so on. whereas, for fractional part, positions are from left to right are as 2^{-1}, 2^{-2}, 2^{-3}, 2^{-4}… and so on for the fractional part.
Example 1 : Convert (11001010)_{2} into Decimal Number System
= (11001010)_{2} = 1x2^{7}+1x2^{6}+0x2^{5}+0x2^{4}+1x2^{3}+0x2^{2}+1x2^{1}+0x2^{0} = 128+64+0+0+8+0+2+0 = (202)_{10}
Example 2 : Convert (1010.01)_{2} into Decimal Number System
= (1010.01)_{2} = 1×2^{3} + 0x2^{2} + 1×2^{1}+ 0x2^{0} + 0x2 ^{-1} + 1×2 ^{-2} = 8+0+2+0+0+0.25 = (10.25)_{10}
Decimal to Binary Number system
By repeatedly dividing a number by 2 and recording the remainder from LSB to MSG, decimal numbers can be converted to binary.
For the fractional part, we multiply this number by 2, and from the result, we store the value of the integer part only, in a sequence. And the process can be repeated until the number become zero or sometime we left after 2/3 steps.
Example 1 : Convert (43)_{10} into Binary Number system
Example 2 : Convert (10.25)_{10} into Binary Number system
Binary to Octal Number System
Since the octal number system has only eight digits (from 0 to 7), we can represent any digit using only three bits, as in the example below.
Example 1 : Convert (1010111100)_{2} into octal number
Diving binary digits into groups of three & converting each group of three in binary digit, we get
= (1010111100)_{2} = (001 010 111 100)_{2} = (1 2 7 4)_{8} = (1274)_{8}
Example 2 : Convert binary number 0110 011.1011 into octal number.
Diving binary digits into groups of three & converting each group of three into the binary digits. Starting from Right for the integer part and starting from left for the fraction part.
= (0110 011.1011)_{2} Grouping above binary number in 3-bit basis we get, = (0 110 011 . 101 1)_{2} = (110 011 . 101 100)_{2} Writing the equivalent Octal number we get, = (6 3 . 5 4)_{8} = (63.54)_{8}
Octal to Binary Number System
This conversion is just an opposite of Binary to Octal Conversion. In this, converting each octal number into binary in three-bit-basis and then combining all binary digits into one.
This can be much clear with the following example:
Example 1 : Convert (120)_{8} into a binary number.
Writing the equivalent Binary number in 3-bit basis we get, 120_{8} = (001 010 000)_{2} Since zeros on the left can be ignored. Thus, 120_{8} = (1010000)_{2}
Example 2 : Convert (352.563)_{8} into binary number.
= (352.563)_{8} Writing the equivalent Binary number in 3-bit basis we get, = (011 101 010 . 101 110 011)_{2} = (011101010.101110011)_{2}
Binary to Hexadecimal Number System
We can represent any digit of the hexadecimal number system using only 4-bit binary numbers. Hence, each group of 4-bit binary numbers is replaced with its corresponding hexadecimal digits. The conversion process is similar to the Octal Number system as described above.
Example 1 : Convert (1010101101001 )_{2} into hexadecimal number.
= (1010101101001)_{2} Grouping above binary number in 4-bit basis we get, = (1 0101 0110 1001)_{2} = (0001 0101 0110 1001)_{2} Writing the equivalent Hexadecimal number we get, = (1 5 6 9)_{16} = (1569)_{16}
Example 2 : Convert (001100101.110111)_{2} into hexadecimal number.
= (001100101.110111)_{2} = (0 0110 0101 . 1101 1100)_{2} = (0110 0101 . 1101 1100)_{2} = (6 5 . D C)_{16} = (65.DC)_{16}
Hexadecimal to Binary Number System
Hexadecimal number can be converted to a binary number by converting each hexadecimal digit to its 4-bit equivalent binary bits.
Example 1 : Convert (BCA)_{16} into a binary number.
Writing the equivalent Binary number in a 3-bit basis we get, (BCA)_{16} = (1011 1100 1010)_{2} Now combining all bits together we get the final answer (BCA)_{16} = (101111001010)_{2}
Example 2 : Convert (35.1A)_{16} into binary number.
= (35.1A)_{16} Writing the equivalent Binary number in 4-bit basis we get, = (0011 0101 . 0001 1010)_{2} = (00110101.00011010)_{2}
Octal to Decimal Number System
The conversion can be done by showing each digit multiplied with 8 as an increasing power as shown in the example below: (This process is similar to Binary > Decimal conversion)
Example 1 : Convert (345)_{8} into Decimal Number system.
(345)_{8} = (3 * 8^{2}) + (4 * 8^{1}) + (5 * 8^{0}) = (3 * 64) + (4 * 8) + (5 * 1) = (229)_{10}
Example 2 : Convert (15.10)_{8} into Decimal Number system.
(15.10)_{8} = (1 * 8^{1}) + (5 * 8^{0}) + (1 * 8^{-1}) + (0 * 8^{-2}) = 8 + 5 + 0.125 + 0 = (13.125)_{10}
Decimal to Octal Number System
This conversion can be done by performing short division by 8 with remainder (Similar as in Decimal to Binary Conversion).
Example 1 : Convert (100)_{10} into Octal Number system.
Example 2 : Convert (0.342)_{10} into Octal Number system.
Octal to Hexadecimal Number System
The binary method can be used to convert an octal number to a hexadecimal number and vice versa. There is no direct conversion method to convert Octal to Hexadecimal. Hence, we will first convert Octal to Binary & then Binary to Hexadecimal.
Example 1 : Convert (456)_{8} into Hexadecimal Number system.
Hexadecimal to Octal Number System
Here, we will first convert Hexadecimal to Binary & then Binary to Octal number system.
Example 1 : Convert (4DF)_{16} into Octal Number system.
Decimal to Hexadecimal Number System
Example 1 : Convert (2545)_{10} into Hexadecimal Number system.
Example 2 : Convert (0.342)_{10} into Hexadecimal Number system.
Therefore (0.342)_{10} = (0.578)_{16}
Hexadecimal to Decimal Number System
Example 1 : Convert (ABC)_{16} into decimal number.
Since, A = 10, B = 11 & C = 12. The equivalent decimal number is calculated below:
= (ABC)_{16} = (10x16^{2}+11x16^{1}+12x16^{0})_{10} = (256 + 176 + 12)_{10} = (444)_{10}
Example 2 : Convert (1F.01B)_{16} into decimal number.
Since, B = 11 & F = 15. Hence, equivalent decimal number is calculated below:
= (1F.01B)_{16} = (1x16^{1}+15x16^{0} +0x16^{-1}+1x16^{-2}+11x16^{-3})_{10} = (31.0065918)_{10} which is answer.
It is very helpful..
Thank you Umesh!