Skip to content
/ Graphing calculator / Binary, hex and decimal converter

Binary, hex and decimal converter

Conversion between bases 2, 8, 10, 16 and any base from 2 to 36, with the working shown as in a computer science class: digits × powers, repeated division, repeated multiplication for the fractional part (the repeating binary expansion of 0.1). Signed integers in two's complement, bitwise operations and IEEE 754 floating-point representation.

Frequently asked questions

How do you convert a decimal number to binary?

Divide the number by 2, then the quotient by 2, and so on until the quotient is 0; read the remainders from bottom to top. 13 = 2 × 6 + 1, 6 = 2 × 3 + 0, 3 = 2 × 1 + 1, 1 = 2 × 0 + 1: 13 is 1101 in binary. For a fractional part, multiply it by 2 and keep the integer part, one digit at a time.

How do you write a negative integer in two's complement?

On n bits, write |x| in binary, invert every bit, then add 1. On 8 bits, for −42: 42 = 00101010, inverted 11010101, plus 1: 11010110. This is the same as writing 2ⁿ + x in binary (256 − 42 = 214).

Why is 0.1 + 0.2 not equal to 0.3 in Python?

0.1 has an infinite binary expansion (0.0001100110011…): the stored float is only an approximation. In double precision, 0.1 is stored as 0.1000000000000000055511151231257827…; the rounding errors of 0.1 and 0.2 add up, and the sum is not exactly the float closest to 0.3.

More calculator pages

How to use it

  1. Conversion: type the number, choose the base it is written in (2, 8, 10, 16 or another base from 2 to 36) and the target base for the steps. The number is shown in the four usual bases, each with a copy button. A fractional part is accepted; a repeating block is overlined.
  2. Signed integers: decimal to two's complement (with the “invert then add 1” method) or a bit string to a signed integer, on 4, 8, 16, 32 or 64 bits.
  3. Bitwise operations: AND, OR, XOR, NOT, shifts, addition and subtraction on n bits, with a and b in decimal, binary (0b1010), octal (0o17) or hexadecimal (0xFF).
  4. IEEE 754 floats: sign, exponent and mantissa of a number in single (32 bits) or double precision (64 bits, Python's float), the value actually stored and the rounding error.

Examples

See also GCD, LCM and number theory and the Python tab of the graphing calculator to program these conversions.

Guide written and checked by the Otoolia team · updated 25 November 2026.