PROJECTENGRAM

NUMBER SYSTEM BASE CONVERSION

Number System Base Conversion

Tags: #◇Computer Science #◇CSARCH1 #◇Problem Solving #◇M2


◇Overview

◇Important Formulas & Algorithms

1. Decimal to Target Base

To convert a decimal number to any target base (e.g., Binary, Octal, Hexadecimal):

  • Integer Part (Whole Number):
    Perform successive ("reverse") division by the target base. Write down the remainders at each step. The final result is read from the last quotient/remainder bottom-up.
  • Fractional Part:
    Perform successive multiplication of the fraction by the target base. Extract the integer part generated at each step. Continue until the fractional part becomes zero (or until 4 decimal places for non-terminating fractions). The result is read top-down.

Example: 6.625106.625_{10} to Binary

  • Integer (6):
    • 6÷2=36 \div 2 = 3 remainder 0
    • 3÷2=13 \div 2 = 1 remainder 1
    • 1÷2=01 \div 2 = 0 remainder 1
    • Read bottom-up: 110
  • Fraction (0.625):
    • 0.625×2=1.2500.625 \times 2 = \mathbf{1}.250 (Extract 1, keep 0.250)
    • 0.250×2=0.5000.250 \times 2 = \mathbf{0}.500 (Extract 0, keep 0.500)
    • 0.500×2=1.0000.500 \times 2 = \mathbf{1}.000 (Extract 1, fraction is now 0)
    • Read top-down: .101
  • Result: 110.1012110.101_2

◇Power-of-Two Conversions (Binary, Octal, Hex)

Because 8=238 = 2^3 and 16=2416 = 2^4, conversions between these bases and binary can be done directly through grouping, without routing through decimal.

Binary ↔\leftrightarrow Octal (Base 8)

  • Rule: 1 Octal digit = 3 Binary bits.
  • Binary to Octal: Starting from the radix point (decimal point), group the binary bits into clusters of 3. Pad with leading/trailing zeros if necessary. Convert each 3-bit cluster into its octal equivalent.
    • Example: 011 101 001.1112→351.78011\ 101\ 001.111_2 \rightarrow 351.7_8
  • Octal to Binary: Convert each octal digit directly into a 3-bit binary sequence.
    • Example: 726.58→111 010 110.1012726.5_8 \rightarrow 111\ 010\ 110.101_2

Binary ↔\leftrightarrow Hexadecimal (Base 16)

  • Rule: 1 Hexadecimal digit = 4 Binary bits (a nibble).
  • Binary to Hex: Starting from the radix point, group bits into clusters of 4. Convert each nibble to its hex equivalent (0-9, A-F).
    • Example: 0111 0101 1001.10112→759.B160111\ 0101\ 1001.1011_2 \rightarrow 759.B_{16}
  • Hex to Binary: Convert each hex digit directly into a 4-bit binary sequence.
    • Example: 829.A16→1000 0010 1001.10102829.A_{16} \rightarrow 1000\ 0010\ 1001.1010_2

Hexadecimal ↔\leftrightarrow Octal

You cannot convert directly between Hex and Octal. You must use Binary as an intermediate bridge.

  • Hex to Octal: Hex →\rightarrow Expand to 4-bit Binary →\rightarrow Regroup into 3-bit Octal.
    • Example (829.A16829.A_{16}):
  1. Hex to Bin: 1000 0010 1001.101021000\ 0010\ 1001.1010_2
  2. Regroup to 3s: 100 000 101 001.101 0002100\ 000\ 101\ 001.101\ 000_2 (added trailing zero)
  3. Bin to Oct: 4051.5084051.50_8
  • Octal to Hex: Octal →\rightarrow Expand to 3-bit Binary →\rightarrow Regroup into 4-bit Hex.

◇General Base Conversion (Base X↔Base YBase\ X \leftrightarrow Base\ Y)

To convert between two non-power-of-two bases (e.g., Base-7 to Base-5), you must use Decimal (Base 10) as the intermediate bridge.

  1. Step 1 (Base X→DecimalBase\ X \rightarrow Decimal): Use positional expansion (summing digits multiplied by their positional weight XiX^i).
  2. Step 2 (Decimal→Base YDecimal \rightarrow Base\ Y): Use the successive division/multiplication algorithm on the resulting decimal number to reach Base Y.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

When converting a decimal fraction to another base, which arithmetic operation is successively used?

Q2

What is the binary equivalent of the decimal number 6?

Q3

What is the hexadecimal equivalent of the decimal number 314?

Q4

How many binary digits are required to represent a single octal digit?

Q5

What is the octal equivalent of the binary number 011 101 001?

Q6

How many binary digits are required to represent a single hexadecimal digit?

Q7

What is the hexadecimal equivalent of the binary number 0111 0101 1001.1011?

Q8

What is the octal equivalent of the hexadecimal number 829.A?

Q9

When converting from decimal to another base, how do you read the integer result after successive division?

Q10

What is the decimal fraction 0.625 represented in hexadecimal?