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
- Graphing calculator (every tab: exact calculations, functions, equations, sequences, statistics, probability, matrices, Python…)
- Limit calculator
- GCD, LCM and number theory
- Inequality solver
- Equation solver
- Sequence calculator
- Statistics and regression
- Probability distributions
- Matrix calculator
- Symbolic algebra (CAS)
- Online Python (NumWorks, TI, Casio)
How to use it
- 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.
- 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.
- 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). - 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
- 2026 = 111 1110 1010 in binary = 7EA in hexadecimal (one hex digit = 4 bits).
- FF in hexadecimal = 255 in decimal; 0.375 = 0.011 in binary.
- 0.1 = 0.0(0011) in binary: the block 0011 repeats forever.
- −42 on 8 bits = 1101 0110 in two's complement.
- 0b1100 AND 0b1010 = 0b1000; 0b1100 XOR 0b1010 = 0b0110.
- 0.1 in single precision: 0x3DCCCCCD, i.e. 0.100000001490116… actually stored.
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.