Number System in Computer, Binary, Octal, Decimal, Hexadecimal
Table of Contents
Number System Introduction:
A finger is also known as a digit. Counting on 10 fingers has led to the Decimal numbers system, in which there are 10 digits including zero. Simply, because we are used to the Decimal numbers system, it appears natural to us. Let’s say if we had 6 fingers, we would have been conversant with the base 6 number system. The rules of arithmetic would be same.
The number system used today, known as the base 10 numbers system, was first introduced / invented by the Egyptians around 3100BC.
A numeral system or system of numeration is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbols may represent different numbers in different numeral systems. For example
11 represents the number Eleven in the decimal number system used in common life, it represents the number three in the binary number system which is used in computers and electronics, and the number two in the unary numeral system.
Number System in computers:
In computers, the main number systems are based on the positional system in base 2 which is known as the binary number system, with two binary digits, 0 and 1. Positional systems obtained by grouping binary digits by three “octal number system” or four “Hexadecimal number system” are commonly used.
Why we need the Binary number system, octal number system, and Hexadecimal number system when we have the Decimal number system?
This is one of the basic questions asked by every beginner. The answer to this question is;
Computer itself has no idea what are the English letters a, b, c,…, z, or numbers, images, etc. Computers, controllers, and other digital systems only know about the ON or OFF “ 1 or 0 “. 1 means High and 0 means low, which represents the voltage and ground. Even right now anything that you can see on your computer screen, cell phone screen, or Tablet, etc these are just the electrical signals.
In digital systems, instructions are given through electric signals; variation is done by varying the voltage of the signal. Having 20 different voltages to implement decimal number system in digital equipment is difficult. So, that’s why other number systems were developed that are easier to implement digitally. We will go through all the number systems in detail. the following table shows the equivalent values of the decimal numbers in Binary, Octal, and Hexadecimal. This a basic table and can be used while doing the conversions.
Binary ()2 | Octal()8 | Decimal ()10 | Hexadecimal ()16 |
0000 | 0 | 0 | 0 |
0001 | 1 | 1 | 1 |
0010 | 2 | 2 | 2 |
0011 | 3 | 3 | 3 |
0100 | 4 | 4 | 4 |
0101 | 5 | 5 | 5 |
0110 | 6 | 6 | 6 |
0111 | 7 | 7 | 7 |
1000 | 10 | 8 | 8 |
1001 | 11 | 9 | 9 |
1010 | 12 | 10 | A |
1011 | 13 | 11 | B |
1100 | 14 | 12 | C |
1101 | 15 | 13 | D |
1110 | 16 | 14 | E |
1111 | 17 | 15 | F |
Binary Number System:
Binary number system is normally implemented in electronic devices as I explained earlier. Due to its internal structure, electronic devices are based on ICs (integrated circuits); ICs are made of logical gates. Logical gates operate on only two values 0 and 1. Each unique value in the binary system is called a BIT, or a Digit. Binary number system has base two-2. We can extract its base from its name “Bi” normally uses to represent two.
To find unique value of the binary number system we can use the formula given below.
{0, base-1}
By putting the value in above formula:
{0, 2-1}
Unique values of binary number system are:
{0, 1}
11010 is a binary number.
In any given binary number, the rightmost digit is called the least significant bit LSB and the leftmost digit is called the most signification bit MSB.
Octal number system:
Octal numbers system normally used in seven segment display systems. This technique is implemented in digital clocks, calculators, digital score boards, and traffic counters etc. Each represented value has its own seven pin structure and number can be extracted by activation of the pins needed for any number. Oct word used for 8, base of the octal number system is 8 so total unique values in octal number system are 8.
To find unique value of the octal number system we use the formula given below.
{0, Base-1}
By putting the value in above formula:
{0, 8-1}
Unique values of octal number system are:
{0, 7}
Now by putting the remaining values after 0 and before 7 we can get complete set of the octal number system unique values:
{0, 1, 2, 3, 4, 5, 6, 7}
Decimal number system:
Decimal number system is used in daily life for calculation purposes. Decimal number system has base of 10 so total unique numbers in a decimal number system are 10. Each value of the decimal number system will be unique from other value. Each value of the decimal number system is called as number.
To find unique value of the decimal number system we can use the formula given below:
{0, Base-1}
By putting the value in above formula:
{0, 10-1}
Unique values of the decimal number system are
{0, 9}
Now by putting the remaining values after 0 and before 9 we can get complete set of decimal number system unique values.
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Hexadecimal number system:
Hexadecimal numbers system has total 16 unique values; we can find the unique values by its name. Hexa is used for 6 and decimal for 10. So by combining both values with each other we can find total unique values of the Hexadecimal number system which is 16. Hexadecimal number system is normally used in computer systems for addressing purpose. Different data we store in computer each of them has a unique address to be resides in the computer memory. When we click on that file or folder computer system extract requested file or folder from memory via its address. Base of the hexadecimal number system is 16.
To find unique values of the hexadecimal number system we can use the formula given below.
{0, Base-1}
By putting the values in above formula:
{0, 16-1}
Unique values of Hexadecimal numbers system are:
{0, 15}
Now by putting the remaining values after 0 and before 15(F) we can get complete set of the Hexadecimal number system unique values. Main point with hexadecimal is that after 9 each new value is represented by the upper case letters of the English from A to F.
{0, F}
Now by putting the remaining values after 0 and before 9 and from A to F we can get complete set of the Hexadecimal numbers system unique values.
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
Conversion from one number system to other Number system:
Conversion from decimal to binary:
To select the values after calculation we take it in two phases
- From left to right in last statement after calculation.
- From bottom to top reminder binary BIT against each statement.
Example: (9867)10 = (?)2
Solution:
2 | 9867 |
2 | 4933—–1 |
2 | 2466—–1 |
2 | 1233—–0 |
2 | 616—–1 |
2 | 308—–0 |
2 | 154—–0 |
2 | 77—–0 |
2 | 38—–1 |
2 | 19—–0 |
2 | 9—–1 |
2 | 4—–1 |
2 | 2—–0 |
1—–0 |
Answer: (9867)10 = (10011010001011)2
When fraction exists in any given value conversion will takes place in two phases
- Convert left hand side of the value dividing by 2.
- Multiply right hand side of the value with 2
- If result has 0 at the start place it after fraction
- If result has non zero value also place 0 follows previous value
- If result has 1 at the start before the fractions place it after previous value
- Apply the multiplication process till last value came 1 or 0.
Example: (839.625)10 = (?)2
L.H.S
2 | 839 |
2 | 419—–1 |
2 | 209—–1 |
2 | 104—–1 |
2 | 52——0 |
2 | 26——0 |
2 | 13——0 |
2 | 6——–1 |
2 | 3——–0 |
1——–1 |
R.H.S
0.625*2 = 1.25——-1
0.25*2 = 0.50——–0
0.50*2 = 1.00——-1
Answer: (893.625)10 = (1101000111.101)2
How to convert a Binary number to Decimal number:
Example: (10010101)2 = (?)
Solution:
=127 + 026 + 025 + 124 + 023 + 022 + 021 + 120
=1128 + 064 + 032 + 116 + 08 + 04 + 02 + 11
=128 + 0 + 0 + 16 + 0 + 4 + 0 + 1
=128 + 16 + 4 + 1
=149
Answer: 149
Example: (100101.101)2 = (?)
Solution:
=125 + 024 + 023 + 122 + 021 + 120 + 12-1 + 02-2 + 1*2-3
=132 + 016 + 08 + 14 + 02 + 11 + 1(1/2) + 0(1/4) + 1*(1/8)
=32 + 0 + 0 + 4 + 0 + 1 + 0.5 + 0 + 0.125
=32+4+1+0.5+0.125
=37.625
Answer: 37.625
Conversion from Binary to Hexadecimal:
To convert any number from binary to hexadecimal number system follow the given below steps:
- Make three, four digits group from right to left.
- If last tetra (four digits group) remains incomplete means only one digit two or three digits add required zeroes to its left most side of the MSB.
- Check the tetra digit equal value written against it in hexadecimal table.
- Replace each tri group of digits with that hexadecimal value.
Example: (11101001001110101)2 = (?)16
Solution:
You can use the table given above.
0001 1101 0010 0111 0101
1 D 2 7 5
Answer: (1D275)16
Example: (1010101101010101101110.10011100) = (?)16
Solution:
10 1010 1101 0101 0110 1110. 1001 1100
Answer: (2AD56E.9C) 16
Conversion from Binary to Octal:
To convert any numbers from binary to octal numbers system follow the steps given below:
- Make three, three digits from right to left.
- If last tri (three digits group) remains incomplete means only one digit or two digits add required zeroes to its left most side of the MSB.
- Check the tri digit equal value written against it in octal tables.
- Replace each tri group of digits with that octal value.
Example: (10101011001)2= (?)8
Solution:
10 101 011 001
Answer (2531)8
Example: (10011001110110.100101)2 = (?)8
Solution:
10 011 001 110 110. 100 101
Answer = (23166.45)8
Conversion from octal to binary:
Example: (764324)8 = (?)2
Solution:
7 6 4 3 2 4
111 110 100 011 010 100
Answer: (111110100011010100)2
Example: (265473.723)8 = (?)2
Solution:
2 6 5 4 7 3. 7 2 3
010 110 101 100 111 011. 111 010 011
Answer: (010 110101100111011.111010 011)2
Conversion from Octal to Decimal:
Example: (234721)8 = (?)10
Solution:
=285 + 384 + 483 + 782 + 281 +180
=232768 + 34096 + 764 + 2 *8 + 11
=65536 + 12288 + 2048 + 448 +16 + 1
=80337
Answer: (80337)10
Example: (6571.342)8 = (?)10
Solution:
=683 + 582 + 781 + 180 + 38-1 + 48-2 + 2*8-3
=6512 + 564 + 78 + 11 + 3(1/8) + 4(1/64) + 2*(1/512)
=3072 + 320 + 56 + 1 + 3/8 +4/64 + 0.00390625
= 3449 + 320 + 56 + 1 + 0.375 + 0.0625 + 0.00390625
=3449 + 0.44140625
=3449.044140625
Answer: (3449.044140625)10
Conversion from decimal to octal:
Example: (98563)10 = (?)8
Solution:
8 | 98563 |
8 | 12320—–3 |
8 | 1540——-0 |
8 | 192———4 |
8 | 24———-0 |
3————0 |
Answer: (98562)10 = (300403)8
Example: (986547.3125)10 = (?)8
L.H.S
8 | 986547 |
8 | 123318—–3 |
8 | 15414——-6 |
8 | 1926——–6 |
8 | 240———6 |
8 | 30———–0 |
3————6 |
R.H.S
0.3125*8 = 2.5——-2
0.5*8 = 4.00———-4
Answer: (986547.3125)10 = (3606663.24)8
Conversion from Decimal to Hexadecimal:
Example: (9468462410)10 = (?)16
Solution:
16 | 9468462410 |
16 | 598028900—-A |
16 | 3737806——-4 |
16 | 2336050——-6 |
16 | 146003——–2 |
16 | 9125———–3 |
16 | 570————5 |
16 | 35————-A |
16 | 2—————3 |
Answer: (9468462410)10 = (23A53264A)16
Example: (9201476.9765625)10 = (?)16
Solution:
L.H.S
16 | 9201476 |
16 | 575092—–4 |
16 | 35943——-4 |
16 | 2246——–7 |
16 | 140———6 |
16 | 8————C |
R.H.S
- 9765625*16 = 15.625———F
0.625*16 = 10———A
Answer: (9201476.9765625)10 = (8C6744.FA)16
Conversion from Hexadecimal to Binary:
Example: (F67B2A)16 = (?)2
Solution:
F 6 7 B 2 A
111 0110 0111 1011 0010 1010
Answer: (F67B2A)16 = (11101100111101100101010)2
Example: (79AE3.CA1)16 = (?)2
Solution:
7 9 A E 3. C A 1
0111 1001 1010 1110 0011 1100 1010 0001
Answer: (79AE3.CA1)16 = (01111001101011100011.110010100001)2
Conversion from Hexadecimal to octal:
To convert any given value from hexadecimal number system to octal number system. First of all convert value into binary number system than convert the resultant value into octal number system.
Conversion from hexadecimal to decimal:
Example: (9C6B)16 = (?)10
Solution:
=9163 + C162 + 6161 + B160
=9163 + 12162 + 6161 + 11160
=94096 + 12256 + 616 + 111
=36864 + 3072 + 96 + 11
=40043
Answer: (9C6B)16 = (40043)10
Example: (A5E7.1F3)16 = (?)10
Solution:
=A16 3+ 5162 + E161 + 7160 + 116-1 + F16-2 + 3*16-3
= 1016 3 + 5162 + 14161 + 7160 + 116-1 + 1516-2 + 3*16-3
= 104096 + 5256 + 1416 + 7160 + 116-1 + 1516-2 + 3*16-3
= 40960 + 5256 + 1416 + 71 + 1(1/16) + 15(1/16) + 3(1/16)
= 40960 + 1280 + 224 + 7 + 1(1/16) + 15(1/16) + 3*(1/16)
= 40960 + 1280 + 224 + 7 + 0.0625 + 150.0625 + 30.0625
= 40960 + 1280 + 224 + 7 + 0.0625 + 0.9375 + 0.1875
= 42471 + 1.1875
= 42472 .1875
Answer: (A5E7.1F3)16 = (42472.1875)10
ASCII:
ASCII stands for American Standard Code for Information Interchange. ASCII is a seven 7-bit coding system that has 128 “27” possible codes. Apart from the numerical data, computer must handle alphabets, special symbols, mathematical operators, and punctuation marks etc. We have a complete set of characters which are called the alphanumeric codes.
10 digits
7 punctuation marks
26 upper case letters
26 lower case letters
20 to 40 special characters.
Such codes can be developed for different languages which as symbols different than that of the English letters.