Skip to content

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

1011
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.

18
04
12
11

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:

1011 = 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1 = 11

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:

  1. 8 fits in 11: a 1 in the 8s place, 3 left.
  2. 4 doesn't fit in 3: a 0.
  3. 2 fits: a 1, 1 left.
  4. 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.

Try it yourself: free lesson

“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 needed

The ideas behind it

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

Every calculator