Binary / Decimal / Hex Base Converter

Enter a value in any base field and click Convert to see the equivalent in all other bases.

Results will appear here.

Conversion Formulas

Every positional numeral system expresses an integer N as a sum of digit × baseposition:

N = dn·bn + dn-1·bn-1 + … + d1·b1 + d0·b0

  • Any base → Decimal: Multiply each digit by its base raised to its positional power and sum.
  • Decimal → Binary (base 2): Repeatedly divide by 2; remainders (read bottom-up) form the binary digits.
  • Decimal → Octal (base 8): Repeatedly divide by 8; remainders (read bottom-up) form the octal digits.
  • Decimal → Hex (base 16): Repeatedly divide by 16; remainders map to 0–9, A–F.
  • Binary → Hex shortcut: Group binary digits in sets of 4 from the right; each group maps directly to one hex digit.
  • Binary → Octal shortcut: Group binary digits in sets of 3 from the right; each group maps to one octal digit.

Example — Decimal 255:

255 ÷ 2 → remainders: 1,1,1,1,1,1,1,1 → Binary: 11111111
255 ÷ 16 → 15 remainder 15 → Hex: FF
255 ÷ 8 → 31 remainder 7 → 3 remainder 7 → Octal: 377

Assumptions & References

  • Conversion uses JavaScript's built-in parseInt(value, base) and Number.prototype.toString(base), which are exact for integers within the safe integer range (±2⁵³ − 1).
  • Negative numbers are handled with a leading minus sign; two's complement representation is not applied.
  • Hexadecimal digits A–F are displayed in uppercase.
  • Bit length is the minimum number of bits required to represent the absolute value (e.g., 255 → 8 bits).
  • Byte length is ⌈bit length / 8⌉.
  • Reference: Knuth, D. E. — The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, §4.1 Positional Number Systems.
  • IEEE 754 floating-point is not used; all arithmetic is integer-based.

In the network