Number systems form the basis of computer science and mathematics. Understanding how to convert numbers between different systems is essential for programmers, engineers, and students alike. This educational page explores the four primary number systems and provides a step-by-step guide for their inter-conversion.
Number Systems Overview
Decimal (Base-10): The most common number system used in everyday life. It consists of 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Binary (Base-2): Used primarily in computing and digital systems. It consists of two digits: 0 and 1.
Octal (Base-8): Often used as a shorthand representation of binary numbers. It consists of eight digits: 0 to 7.
Hexadecimal (Base-16): Commonly used in programming and memory addressing. It consists of 16 symbols: 0 to 9 and A (10), B (11), C (12), D (13), E (14), F (15).
Conversion Methods
1. Decimal to Binary
Divide the decimal number by 2.
Record the remainder (0 or 1).
Continue dividing the quotient by 2 until the quotient is 0.
Write the remainders in reverse order.
Example: Convert 25 (Decimal) to Binary.
25 ÷ 2 = 12 R1
12 ÷ 2 = 6 R0
6 ÷ 2 = 3 R0
3 ÷ 2 = 1 R1
1 ÷ 2 = 0 R1 Result: 25 (Decimal) = 11001 (Binary)
2. Binary to Decimal
Write the binary number.
Multiply each digit by 2 raised to the power of its position (starting from 0, from right to left).
Sum all the results.
Example: Convert 11001 (Binary) to Decimal.
(1 x 2^4) + (1 x 2^3) + (0 x 2^2) + (0 x 2^1) + (1 x 2^0)
= 16 + 8 + 0 + 0 + 1 = 25 Result: 11001 (Binary) = 25 (Decimal)
3. Decimal to Octal
Divide the decimal number by 8.
Record the remainder.
Continue dividing the quotient by 8 until the quotient is 0.
Write the remainders in reverse order.
Example: Convert 65 (Decimal) to Octal.
65 ÷ 8 = 8 R1
8 ÷ 8 = 1 R0
1 ÷ 8 = 0 R1 Result: 65 (Decimal) = 101 (Octal)
4. Octal to Decimal
Write the octal number.
Multiply each digit by 8 raised to the power of its position (starting from 0, from right to left).
Sum all the results.
Example: Convert 101 (Octal) to Decimal.
(1 x 8^2) + (0 x 8^1) + (1 x 8^0)
= 64 + 0 + 1 = 65 Result: 101 (Octal) = 65 (Decimal)
5. Decimal to Hexadecimal
Divide the decimal number by 16.
Record the remainder.
Continue dividing the quotient by 16 until the quotient is 0.
Write the remainders in reverse order, using hexadecimal symbols (A-F for remainders 10-15).
Example: Convert 255 (Decimal) to Hexadecimal.
255 ÷ 16 = 15 R15 (F)
15 ÷ 16 = 0 R15 (F) Result: 255 (Decimal) = FF (Hexadecimal)
6. Hexadecimal to Decimal
Write the hexadecimal number.
Multiply each digit by 16 raised to the power of its position (starting from 0, from right to left).
Sum all the results.
Example: Convert FF (Hexadecimal) to Decimal.
(15 x 16^1) + (15 x 16^0)
= 240 + 15 = 255 Result: FF (Hexadecimal) = 255 (Decimal)
7. Binary to Octal
Group the binary digits in sets of three (starting from the right).
Convert each group to its octal equivalent.
Example: Convert 11001 (Binary) to Octal.
Group: 000 110 001
Convert: (000 = 0), (110 = 6), (001 = 1) Result: 11001 (Binary) = 61 (Octal)
8. Binary to Hexadecimal
Group the binary digits in sets of four (starting from the right).
Convert each group to its hexadecimal equivalent.
Example: Convert 11111111 (Binary) to Hexadecimal.
Group: 1111 1111
Convert: (1111 = F), (1111 = F) Result: 11111111 (Binary) = FF (Hexadecimal)
9. Octal to Binary
Convert each octal digit to its 3-bit binary equivalent.
Example: Convert 61 (Octal) to Binary.
- Convert: (6 = 110), (1 = 001) Result: 61 (Octal) = 110001 (Binary)
10. Hexadecimal to Binary
Convert each hexadecimal digit to its 4-bit binary equivalent.
Example: Convert FF (Hexadecimal) to Binary.
- Convert: (F = 1111), (F = 1111) Result: FF (Hexadecimal) = 11111111 (Binary)
Practice Problems
Convert 100 (Decimal) to Binary, Octal, and Hexadecimal.
Convert 11010 (Binary) to Decimal and Hexadecimal.
Convert 77 (Octal) to Binary and Decimal.
Convert 1A3 (Hexadecimal) to Binary and Decimal.
By practicing these conversions, you can master the art of inter-converting between number systems, a fundamental skill in computer science and mathematics.