Skip to main content
返回指南
6 min read5 步骤

How to Convert Between Binary, Decimal, Hexadecimal, and Octal: Step-by-Step Guide

Learn to manually convert numbers between binary, decimal, hexadecimal, and octal systems. Master formulas, worked examples, and common pitfalls.

跳过数学——使用计算器

分步说明

1

Understand Number Systems and Place Values

First, identify the base of each number system: Binary (base-2), Octal (base-8), Decimal (base-10), and Hexadecimal (base-16). Understand that each digit's position corresponds to a power of its base, starting from 0 for the rightmost digit (e.g., ... Base^2, Base^1, Base^0).

2

Convert from Any Base to Decimal

To convert a number from any base (B) to decimal, multiply each digit by B raised to the power of its position, then sum these products. For example, for 1101_2, calculate (1*2^3) + (1*2^2) + (0*2^1) + (1*2^0) = 8 + 4 + 0 + 1 = 13_10.

3

Convert from Decimal to Any Base

To convert a decimal number to another base (B), repeatedly divide the decimal number by B and record the remainders. Continue until the quotient is 0. The new number in base B is formed by reading the remainders from bottom to top (last remainder to first). For example, 13_10 to binary: 13/2=6 R1, 6/2=3 R0, 3/2=1 R1, 1/2=0 R1. Reading up: 1101_2.

4

Convert Between Binary, Octal, and Hexadecimal

For Binary to Octal, group binary digits in threes from the right (add leading zeros if needed) and convert each group to its octal equivalent. For Binary to Hexadecimal, group in fours. For Octal/Hexadecimal to Binary, convert each digit to its 3-bit/4-bit binary equivalent, respectively.

5

Verify Your Calculations and Avoid Pitfalls

Always double-check your arithmetic, especially place values and hexadecimal digit mappings (A-F). Ensure correct grouping (3 bits for octal, 4 bits for hex) and remember to read remainders in reverse order. For large numbers or quick checks, utilize an online converter for speed and accuracy verification.

Introduction to Number Systems

Digital systems and computer science frequently utilize various number systems beyond the familiar decimal (base-10) system. Understanding how to convert between binary (base-2), octal (base-8), and hexadecimal (base-16) is fundamental for anyone working with data representation, memory addressing, or low-level programming. This guide will teach you the manual methods, providing the underlying formulas and practical examples.

Prerequisites

Before you begin, ensure you have a basic understanding of:

  • Place Value: How the position of a digit in a number determines its value (e.g., in 123, '1' represents 100).
  • Exponents: Understanding powers of a base (e.g., 2^0=1, 2^1=2, 16^0=1).
  • Basic Arithmetic: Addition, subtraction, multiplication, and division.

Conversion Principles

The core of number system conversion relies on two fundamental principles:

  1. Any Base to Decimal: To convert a number from any base (B) to decimal (base-10), multiply each digit by B raised to the power of its position (starting from 0 for the rightmost digit), then sum the results.
    • Formula: Decimal = Σ (digit * Base^position)
  2. Decimal to Any Base: To convert a decimal number to another base (B), repeatedly divide the decimal number by B, recording the remainders. The new number is formed by reading the remainders from bottom to top (last remainder to first).

Step 1: Understand Number Systems and Place Values

Each number system uses a specific "base" (or radix) which defines the number of unique digits it employs.

  • Binary (Base-2): Uses two digits: 0, 1. Each position represents a power of 2.
  • Octal (Base-8): Uses eight digits: 0-7. Each position represents a power of 8.
  • Decimal (Base-10): Uses ten digits: 0-9. Each position represents a power of 10.
  • Hexadecimal (Base-16): Uses sixteen symbols: 0-9 and A, B, C, D, E, F (A=10, B=11, C=12, D=13, E=14, F=15). Each position represents a power of 16.

The place value for digits in any number system follows the pattern: ... Base^3, Base^2, Base^1, Base^0 for integers.

Step 2: Convert from Any Base to Decimal

This method uses the formula Decimal = Σ (digit * Base^position).

Binary to Decimal

Worked Example: Convert 1101_2 to Decimal

  1. Identify digits and positions (from right, starting at 0):
    • 1 at position 3 (2^3)
    • 1 at position 2 (2^2)
    • 0 at position 1 (2^1)
    • 1 at position 0 (2^0)
  2. Apply the formula: (1 * 2^3) + (1 * 2^2) + (0 * 2^1) + (1 * 2^0) = (1 * 8) + (1 * 4) + (0 * 2) + (1 * 1) = 8 + 4 + 0 + 1 = 13_10

Octal to Decimal

Worked Example: Convert 37_8 to Decimal

  1. Identify digits and positions:
    • 3 at position 1 (8^1)
    • 7 at position 0 (8^0)
  2. Apply the formula: (3 * 8^1) + (7 * 8^0) = (3 * 8) + (7 * 1) = 24 + 7 = 31_10

Hexadecimal to Decimal

Worked Example: Convert 2A_16 to Decimal (Remember A = 10)

  1. Identify digits and positions:
    • 2 at position 1 (16^1)
    • A (10) at position 0 (16^0)
  2. Apply the formula: (2 * 16^1) + (10 * 16^0) = (2 * 16) + (10 * 1) = 32 + 10 = 42_10

Step 3: Convert from Decimal to Any Base

This method involves repeated division by the target base.

Decimal to Binary

Worked Example: Convert 13_10 to Binary

  1. Divide 13 by 2: 13 / 2 = 6 remainder 1
  2. Divide 6 by 2: 6 / 2 = 3 remainder 0
  3. Divide 3 by 2: 3 / 2 = 1 remainder 1
  4. Divide 1 by 2: 1 / 2 = 0 remainder 1
  5. Read remainders from bottom to top: 1101_2

Decimal to Octal

Worked Example: Convert 42_10 to Octal

  1. Divide 42 by 8: 42 / 8 = 5 remainder 2
  2. Divide 5 by 8: 5 / 8 = 0 remainder 5
  3. Read remainders from bottom to top: 52_8

Decimal to Hexadecimal

Worked Example: Convert 42_10 to Hexadecimal

  1. Divide 42 by 16: 42 / 16 = 2 remainder 10 (which is A in hex)
  2. Divide 2 by 16: 2 / 16 = 0 remainder 2
  3. Read remainders from bottom to top: 2A_16

Step 4: Convert Between Binary, Octal, and Hexadecimal

These conversions are efficient because octal (8 = 2^3) and hexadecimal (16 = 2^4) are powers of two.

Binary to Octal

Group binary digits in threes from the right, adding leading zeros if necessary, then convert each group to its octal equivalent.

Worked Example: Convert 11011010_2 to Octal

  1. Group in threes from the right: 11 | 011 | 010 (add a leading zero to the first group: 011)
  2. Convert each group:
    • 011_2 = 3_8
    • 011_2 = 3_8
    • 010_2 = 2_8
  3. Combine the results: 332_8

Octal to Binary

Convert each octal digit to its 3-bit binary equivalent.

Worked Example: Convert 332_8 to Binary

  1. Convert each digit:
    • 3_8 = 011_2
    • 3_8 = 011_2
    • 2_8 = 010_2
  2. Combine the results: 011011010_2 (leading zeros can be dropped: 11011010_2)

Binary to Hexadecimal

Group binary digits in fours from the right, adding leading zeros if necessary, then convert each group to its hexadecimal equivalent.

Worked Example: Convert 11011010_2 to Hexadecimal

  1. Group in fours from the right: 1101 | 1010
  2. Convert each group:
    • 1101_2 = D_16
    • 1010_2 = A_16
  3. Combine the results: DA_16

Hexadecimal to Binary

Convert each hexadecimal digit to its 4-bit binary equivalent.

Worked Example: Convert DA_16 to Binary

  1. Convert each digit:
    • D_16 (13) = 1101_2
    • A_16 (10) = 1010_2
  2. Combine the results: 11011010_2

Step 5: Common Pitfalls and When to Use a Calculator

Common Pitfalls to Avoid:

  • Incorrect Place Values: Always start position 0 from the rightmost digit for the integer part.
  • Hexadecimal Digit Errors: Remember that A-F represent 10-15.
  • Grouping Mistakes: For binary to octal, use 3-bit groups; for binary to hexadecimal, use 4-bit groups. Group from the right and add leading zeros if needed.
  • Arithmetic Errors: Double-check your multiplication, addition, and division.
  • Reversing Remainders: When converting from decimal to another base, always read the remainders from bottom to top.

When to Use an Online Converter:

While manual conversion builds a deep understanding, an online binary converter or calculator is invaluable for:

  • Large Numbers: Converting very long binary strings or large decimal numbers manually is tedious and highly prone to error.
  • Speed: For quick, on-the-spot conversions in a professional setting.
  • Verification: To check your manual calculations and ensure accuracy, especially when learning.
  • Complex Scenarios: Dealing with fractional parts or very specific data formats.

Mastering these manual conversion techniques provides a solid foundation for understanding how computers process and store information.

准备好计算了吗?

跳过手动工作并立即获得结果。

打开计算器

设置

隐私条款关于© 2026 PrimeCalcPro