DEV Community

Cover image for Master Number Conversions with Ease: From Binary to Hexadecimal & More!
Md Nazmus Sakib
Md Nazmus Sakib

Posted on

Master Number Conversions with Ease: From Binary to Hexadecimal & More!

Number systems are an essential part of computer science and mathematics. Understanding how to convert between these systems is crucial for solving problems in digital systems, programming, and networking.

This guide will walk you through the rules, methods, and examples for number conversions, including:

  • Binary to Decimal
  • Decimal to Binary
  • Binary to Octal
  • Octal to Binary
  • Binary to Hexadecimal
  • Hexadecimal to Binary
  • Decimal to Octal
  • Octal to Decimal
  • Decimal to Hexadecimal
  • Hexadecimal to Decimal
  • Octal to Hexadecimal
  • Hexadecimal to Octal

We'll include images to help visualize the processes.


1. Binary to Decimal

Conversion Rule:

  1. Write down the binary number.
  2. Multiply each binary digit by 2 raised to the power of its position, starting from 0 on the right.
  3. Sum all the results to get the decimal value.

Example:

Binary: 1011

Calculation:
[
(1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 8 + 0 + 2 + 1 = 11
]
Decimal: 11


2. Decimal to Binary

Conversion Rule:

  1. Divide the decimal number by 2.
  2. Record the remainder.
  3. Continue dividing the quotient by 2 until the quotient is 0.
  4. Write the remainders in reverse order.

Example:

Decimal: 13

Calculation:

  • 13 \div 2 = 6 remainder 1
  • 6 \div 2 = 3 remainder 0
  • 3 \div 2 = 1 remainder 1
  • 1 \div 2 = 0 remainder 1

Binary: 1101


3. Binary to Octal

Conversion Rule:

  1. Group binary digits into sets of three, starting from the right. Add leading zeros if necessary.
  2. Convert each group into its octal equivalent.

Example:

Binary: 101101

Group: 000 101 101
Octal: 5 5

Result: 55


4. Octal to Binary

Conversion Rule:

  1. Convert each octal digit into its 3-bit binary equivalent.

Example:

Octal: 25

Conversion:

  • 2 = 010
  • 5 = 101

Binary: 010101


5. Binary to Hexadecimal

Conversion Rule:

  1. Group binary digits into sets of four, starting from the right. Add leading zeros if necessary.
  2. Convert each group into its hexadecimal equivalent.

Example:

Binary: 11010111

Group: 1101 0111
Hexadecimal:

  • 1101 = D
  • 0111 = 7

Result: D7


6. Hexadecimal to Binary

Conversion Rule:

  1. Convert each hexadecimal digit into its 4-bit binary equivalent.

Example:

Hexadecimal: A3

Conversion:

  • A = 1010
  • 3 = 0011

Binary: 10100011


7. Decimal to Octal

Conversion Rule:

  1. Divide the decimal number by 8.
  2. Record the remainder.
  3. Continue dividing the quotient by 8 until the quotient is 0.
  4. Write the remainders in reverse order.

Example:

Decimal: 65

Calculation:

  • 65 \div 8 = 8 remainder 1
  • 8 \div 8 = 1 remainder 0
  • 1 \div 8 = 0 remainder 1

Octal: 101


8. Octal to Decimal

Conversion Rule:

  1. Multiply each digit by 8 raised to the power of its position, starting from 0 on the right.
  2. Sum all the results.

Example:

Octal: 45

Calculation:
[
(4 \times 8^1) + (5 \times 8^0) = 32 + 5 = 37
]
Decimal: 37


9. Decimal to Hexadecimal

Conversion Rule:

  1. Divide the decimal number by 16.
  2. Record the remainder.
  3. Continue dividing the quotient by 16 until the quotient is 0.
  4. Write the remainders in reverse order.

Example:

Decimal: 255

Calculation:

  • 255 \div 16 = 15 remainder 15 (F)
  • 15 \div 16 = 0 remainder 15 (F)

Hexadecimal: FF


10. Hexadecimal to Decimal

Conversion Rule:

  1. Multiply each digit by 16 raised to the power of its position, starting from 0 on the right.
  2. Sum all the results.

Example:

Hexadecimal: 1A

Calculation:
[
(1 \times 16^1) + (A \times 16^0) = 16 + 10 = 26
]
Decimal: 26


11. Octal to Hexadecimal

Conversion Rule:

  1. Convert the octal number to binary.
  2. Group binary digits into sets of four.
  3. Convert each group into its hexadecimal equivalent.

Example:

Octal: 17

Binary: 001 111
Hexadecimal: F


12. Hexadecimal to Octal

Conversion Rule:

  1. Convert the hexadecimal number to binary.
  2. Group binary digits into sets of three.
  3. Convert each group into its octal equivalent.

Example:

Hexadecimal: 2F

Binary: 0010 1111
Group: 010 111
Octal: 27


At last

Number conversions are vital for various applications in computing and digital systems. Understanding these methods ensures that you can navigate between binary, decimal, octal, and hexadecimal systems with ease.

For further visualization, reference images and charts will be useful for practice. Consistently practicing these conversions will solidify your skills.

Top comments (0)