This project helps to convert a number that is in decimal or binary or octal or hexadecimal to any other type.
First, understand the different type of standard number systems:
1.) Decimal: Decimal numbers are usual numbers which we use in our day-to-day life. The base of the decimal number system is 10 i.e. 0 to 9.
2.) Binary: In the binary number system there are only two digits 0 and 1. Since there are only two numbers so its base is 2.
3.) Octal: Octal number system has eight numbers from 0 to 7. The base of the number system is 8.
4.) Hexadecimal: In the hexadecimal number system, there are 16 numbers from 0 to 9, and digits 10 to 15 are represented by A to F. The base of the hexadecimal number system is 16.
The project contains 12 cases in the program:
1.) Decimal to Binary: For Example, Convert 244 into a binary number.
Division of Decimal Number by 2 |
Quotient |
Remainder |
Binary |
244/2 |
122 |
0 |
0 (LSB) |
122/2 |
61 |
0 |
0 |
61/2 |
30 |
1 |
1 |
30/2 |
15 |
0 |
0 |
15/2 |
7 |
1 |
1 |
7/2 |
3 |
1 |
1 |
3/2 |
1 |
1 |
1 |
1/2 |
0 |
1 |
1 (MSB |
So the binary number of 244 is 11110100.
2.) Decimal to Octal: For Example, Convert 244 into an octal number.
Division of Decimal Number by 2 |
Quotient |
Remainder |
Octal |
244/8 |
30 |
4 |
4 (LSB) |
30/8 |
3 |
6 |
6 |
3/8 |
0 |
3 |
3 (MSB) |
So the octal number of 244 is 364.
3.) Decimal to Hexadecimal: For Example, Convert 244 into a hexadecimal number.
Division of Decimal Number by 2 |
Quotient |
Remainder |
Hexadecimal |
244/16 |
15 |
4 |
4 (LSB) |
15/16 |
0 |
15 |
15=F(MSB) |
So the hexadecimal number of 244 is F4.
4.) Binary to Decimal: For Example, Convert 11110100 into a decimal number.
11110100 => (1 × 2⁷) + (1 × 2⁶) + (1 × 2⁵) + (1 × 2⁴) + (0 × 2³) + (1 × 2²) + (0 × 2¹) + (0 × 2⁰) = 244
5.) Binary to Octal: First convert the binary number into a decimal number then convert the decimal number into an octal number.
6.) Binary to Hexadecimal: First convert the binary number into a decimal number then convert the decimal number into a hexadecimal number.
7.) Octal to Binary: First convert the octal number into a decimal number then convert the decimal number into a binary number.
8.) Octal to Decimal: For Example, Convert 364 into a decimal number.
364 => (3 × 8²) + (6 × 8¹) + (4 × 8⁰) = 244
9.) Octal to Hexadecimal: First convert the octal number into a decimal number then convert the decimal number into a hexadecimal number.
10.) Hexadecimal to Binary: First convert the hexadecimal number into a decimal number then convert the decimal number into a binary number.
11.) Hexadecimal to Decimal: For Example, Convert F4 into a decimal number.
F4 => (15 × 16¹) + (4 × 16⁰) = 244
12.) Hexadecimal to Octal: First convert the hexadecimal number into a decimal number then convert the decimal number into an octal number.
Submitted by Shiddhant Gupta (Shiddhant123)
Download packets of source code on Coders Packet
Comments