Free calculator
Binary, decimal and hex converter
Binary counts with two digits, 0 and 1, and each place is worth double the one to its right: 1, 2, 4, 8 and on. Type a number in any box, decimal, binary or hex, to see it in the others, with each bit's place value shown and added up.
Ordinary counting, digits 0–9.
Only 0s and 1s. Spaces are fine.
0–9, then A–F for 10–15.
In binary
- Decimal
- 11
- Hexadecimal
- 0xB
- Bits shown
- 4
- Biggest 4 bits can count
- 15
- Gray code
- 1110
- Every bit flipped
- 0100
Place values
Each place is worth double the one to its right. Add up the places that hold a 1.
8 + 2 + 1 = 11
Place values
Each bit's place is worth double the one before. To read a binary number, add up the places that hold a 1:
n bits make 2n patterns, from 0 to 2n − 1. Four bits count to 15, eight bits (a byte) to 255, and ten bits, like an Arduino's analog input, to 1023.
A worked example
To write 11 in binary, start at the biggest place that fits and work down:
- 8 fits in 11: a 1 in the 8s place, 3 left.
- 4 doesn't fit in 3: a 0.
- 2 fits: a 1, 1 left.
- 1 fits: a 1.
So 11 is 1011, and in hex it's B, the digit for 11.
Hex, Gray code and flipped bits
Hexadecimal packs four bits into one digit, so programmers use it to write bytes short: 1111 1111 is FF. Gray code reorders the patterns so counting up changes just one bit at a time, which is why position sensors use it. Every bit flipped, the ones' complement, turns each 1 into a 0 and back, within the bits shown.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“One or zero” is lesson 1 of 6 in Gate Grove, Digital Logic World 1. Free with an account. It’s open as soon as you sign up.
Or start from the very first lesson, no account neededThe ideas behind it
- Binary numbers explainedPlaces worth 1, 2, 4 and 8: add up the bits that are on, and four wires count to 15.
- What is Gray code, and why do encoders use it?A count where only one bit changes per step, and why encoders depend on it.
- What is ones' complement? Flip the bits, get the max minus nFlip every bit and you get the biggest number minus the one you started with. A counter does it for free.
Questions people ask
How do you convert binary to decimal?
Multiply each bit by its place value and add them up. From the right, the places are worth 1, 2, 4, 8, 16 and so on, each double the last. So 1011 is 8 + 0 + 2 + 1 = 11.
How do you convert decimal to binary?
Start at the biggest place value that fits, write a 1 there and subtract it, then work down: 1 if the place fits what's left, 0 if it doesn't. For 11: 8 fits (3 left), 4 doesn't, 2 fits (1 left), 1 fits. So 11 is 1011.
How do you convert binary to hex?
Split the bits into groups of four from the right, and write each group as one hex digit: 0–9, then A–F for 10–15. 1111 1111 is FF, which is 255, and 1101 is D.
More calculators
- Ohm's law calculatorAny two of V, I and R give the third, and the power.
- Electrical power calculatorWatts from any two of V, I and R, and the resistor rating that stays cool.
- LED resistor calculatorThe resistor for one LED or a string, rounded to a value you can buy.
- Resistor colour code calculatorBands to ohms, or ohms to bands, on 4- and 5-band resistors.
- Resistors in series and parallel calculatorThe total of up to eight resistors, in series or in parallel.
- Voltage divider calculatorVout from two resistors, or the resistor for the Vout you need.