Math calculators

Number base converter

Binary, octal, decimal, hexadecimal and any base from 2 to 36, including fractional parts and two's complement.

Inputs

Results

Methodology

Conventions

  • Conversion is exact for whole numbers of any length. Digits above 9 are the letters a to z.
  • Fractional parts are converted digit by digit; a fraction that does not terminate in the target base is cut at the chosen number of digits and marked inexact.
  • Two's complement shows the bit pattern of a whole number in 8, 16, 32 or 64 bits.

References

  • Knuth, The Art of Computer Programming, vol. 2, ยง4.4

Formulas

Value
(d_k \ldots d_0 . d_{-1} \ldots)_b = \sum_i d_i b^i
Two's complement
x < 0 \Rightarrow 2^n + x