ElectroHub

Number Base Converter

Digital work moves constantly between bases: binary for what the hardware does, hex for writing it down compactly, decimal for humans. This converts in every direction and shows the arithmetic.

Number Base Converter

Convert an integer between binary, octal, decimal and hexadecimal, with the fixed-width two's-complement pattern for signed values. Pick the base you're typing in above.

Binary
Octal
Decimal
Hexadecimal
Two's complement (8-bit)
Hex (8-bit)
  1. 1.Input "42" read as decimal = 42 in decimal
  2. 2.Convert decimal → binary by repeated division by 2:
  3. 3.Formuladivide, note remainderSubstitute42 ÷ 2 = 21 remainder 0
  4. 4.FormulaSubstitute21 ÷ 2 = 10 remainder 1
  5. 5.FormulaSubstitute10 ÷ 2 = 5 remainder 0
  6. 6.FormulaSubstitute5 ÷ 2 = 2 remainder 1
  7. 7.FormulaSubstitute2 ÷ 2 = 1 remainder 0
  8. 8.FormulaSubstitute1 ÷ 2 = 0 remainder 1Resultread remainders bottom-up → 101010₂
  9. 9.FormulaGroup the binary in 3s for octal, 4s for hexSubstitute101010₂Result= 52₈ = 2A₁₆
  10. 10.Formula8-bit pattern (positive → same as unsigned)Substitutepad 101010 to 8 bitsResult= 00101010₂ (2A₁₆)
Common trap: Hex and octal are just shorthand for binary — one hex digit is exactly 4 bits, one octal digit exactly 3. And a negative number has no single "binary" form until you fix a width: −1 is 1111 in 4 bits but 11111111 in 8.

The formula

Positional notation: value = Σ dᵢ × baseⁱ

dᵢ
the digit at position i, counting from zero at the right
base
2 (binary), 8 (octal), 10 (decimal) or 16 (hexadecimal)

Worked example

Convert decimal 255 to the other three bases.

  1. Binary: 255 = 128+64+32+16+8+4+2+1 → 11111111
  2. Hex: group the bits in fours — 1111 1111 → F F
  3. Octal: group in threes from the right — 011 111 111 → 377

255₁₀ = 11111111₂ = FF₁₆ = 377₈ — the largest value a single byte can hold.

Where you'll use it

Digital electronics and microprocessor papers, reading register values and setting bit masks. Hex is popular because one hex digit maps exactly to four bits, so conversion is grouping rather than division.

Related calculators