进制转换器公式

Number Base Conversion

Method: Repeated Division

To convert decimal to base b: 1. Divide n by b, record the remainder 2. Replace n with the quotient 3. Repeat until n = 0 4. Read remainders from bottom to top

Common Bases

  • Binary (base-2): 0, 1
  • Octal (base-8): 0-7
  • Decimal (base-10): 0-9
  • Hexadecimal (base-16): 0-9, A-F
  • 计算示例

    Analyze the number 255 in different bases.

    1. 255 in binary: 11111111 (8 binary digits)
    2. 255 in octal: 377 (last digit: 255 mod 8 = 7)
    3. 255 in hex: FF (last digit: 255 mod 16 = 15 = F)
    4. Bits needed: floor(log2(255))+1 = 8