Type a number, say which base it is written in, and see it in binary, octal, decimal and hexadecimal at once, with the working.
Digits 0-9 then A-Z (base 36 at most). A leading minus is read; spaces and underscores group digits; a point or comma starts the fraction.
Try:
Result
1011012 = 4510
In every common base
Binary (2)
101101
Octal (8)
55
Decimal (10)
45
Hexadecimal (16)
2D
Sum of digit × place value
Each digit is multiplied by the base raised to its position, counted from 0 on the right, and the products are added.
1 · 25 = 1 · 32 = 32
0 · 24 = 0 · 16 = 0
1 · 23 = 1 · 8 = 8
1 · 22 = 1 · 4 = 4
0 · 21 = 0 · 2 = 0
1 · 20 = 1 · 1 = 1
Sum: 4510
The target is decimal, so the positional sum above is the whole conversion.
Two’s complement
How a computer stores the whole number 45 in 8, 16 and 32 bits. A negative number is its positive form with every bit flipped and 1 added.
Bits
Binary
Hex
8
00101101
2D
16
0000000000101101
002D
32
00000000000000000000000000101101
0000002D
Working at 8 bits
A non-negative number that fits is its plain binary form, padded with zeros to 8 bits: 00101101.
How to use it
Type the number and pick the base it is written in. Digits are 0-9, then A-Z for bases above 10.
Pick the base you want. Binary, octal, decimal and hexadecimal are always shown; the chosen base is added if it is another.
The working is below: the place-value sum for the base you typed, repeated division for the base you want, and the two’s complement at 8, 16 and 32 bits.
A fraction (10.5 or 10,5) is converted too, to at most 24 digits. The steps and the two’s complement use the whole part only, and the page says so.
Two ways to convert
To decimal: add digit times place value. In binary the places are 1, 2, 4, 8, 16, so 101101 = 32 + 8 + 4 + 1 = 45.
From decimal: divide repeatedly. Divide by the new base, keep each remainder, and continue with the quotient until it is 0. Reading the remainders from the last to the first gives the digits: 45 gives 1, 0, 1, 1, 0, 1 read upwards, so 45 = 101101 in binary.
Two’s complement
Computers store negative whole numbers by flipping every bit of the positive number and adding 1. At 8 bits, −5 starts as 00000101, flipped 11111010, plus one 11111011 (FB). An n-bit signed number holds −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1: −128 to 127 at 8 bits.
Common questions
Why does 0.1 never end in binary?
A fraction ends in a base only if its denominator divides a power of that base. 1/10 has the factor 5, which no power of 2 has, so the binary digits repeat. The converter cuts the expansion rather than rounding it.
Copy the code into your page where the calculator should appear. It loads from lovetocalc.com, so it stays current on its own — all we ask is that the credit line comes with it.