Find a course

Module 2: Converting Binary and DecimalLesson 3 of 1111 min

Binary to Decimal

Convert any binary number to decimal by adding the place values of its 1 bits, check your answers with quick tricks and avoid the common mistakes.

Step 1 of 13Learn

Add up the 1s

Converting binary to decimal is just place value. Write the binary number, write the place values above it from right to left (1, 2, 4, 8, ...), and add the place values wherever there's a 1. Zeros contribute nothing.

Example: convert 101101 to decimal.

32168421
101101

Add the place values under the 1s: 32 + 8 + 4 + 1 = 45.

Another example: 11111111 (eight 1s). That's 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest value a byte can hold.

The single most common mistake is lining up place values from the left. Place values always start at 1 on the right, because the rightmost digit is the ones place, just as in decimal. A 6-bit number's leftmost bit is worth 32, not 1 and not 64. Counting the digits first tells you where to start: for 6 digits, the leftmost is 25 = 32.

Leading zeros don't change the value. 00101101 is still 45, just as 0045 is still 45 in decimal. Computers often show leading zeros to fill a whole byte.

Step 2 of 13Diagram

Decoding 1011

Decoding 1011Parts diagram: 1011 = 11, 8: bit is 1, 4: bit is 0, 2: bit is 1, 1: bit is 1.1011 = 118: bit is 14: bit is 02: bit is 11: bit is 1

Tap a shape with to see more.

8 + 2 + 1 = 11. Only the places holding a 1 are added.
1011 = 11
8: bit is 1

Counts: add 8.

4: bit is 0

Skip it.

2: bit is 1

Add 2.

1: bit is 1

Add 1.

Step 3 of 13Practice · Work it out

Convert the binary number 1101 to decimal.

Step 4 of 13Practice · Work it out

Convert 10010110 to decimal.

Step 5 of 13Flashcards

Binary values worth recognizing

Tap a card to flip it.

Step 6 of 13Learn

Quick checks and shortcuts

A few tricks let you check answers in seconds.

Odd or even. The last bit tells you. If it's 1, the decimal number is odd; if it's 0, it's even. If you convert 10110 and get an odd number, you've made a mistake.

All ones. A binary number of n ones equals 2n − 1. So 1111 = 24 − 1 = 15, and 111111 = 26 − 1 = 63. That's because adding 1 to it would roll over to a 1 followed by n zeros, which is 2n.

A one followed by zeros. 1 followed by n zeros equals 2n. So 1000000 (six zeros) = 64.

Doubling by shifting. Adding a 0 to the right end of a binary number doubles it, just as adding a 0 to a decimal number multiplies by ten. 101 is 5, 1010 is 10 and 10100 is 20. Removing the last bit halves the number and drops any remainder. Computers use this bit shifting as a very fast way to multiply and divide by powers of two.

Size check. A binary number with n digits (starting with 1) is at least 2^(n−1) and less than 2n. A 7-digit binary number must be between 64 and 127. If your conversion lands outside that range, look again.

Step 7 of 13Practice · Match the pairs

Match each binary number to its decimal value without full conversion, using the shortcuts.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. 11111
  2. 100000
  3. 1010
  4. 10100
  5. 1111111

Step 8 of 13Practice · Diagram

Where 8-bit patterns land

Tap the smallest value that has the leftmost bit switched on.

Tap the shape that answers the question, then press Check.

Where 8-bit patterns landScale: 00000000, 00001111, 01000000, 10000000, 11111111.Leftmost bit 0Leftmost bit 1050100150200250000000000150000111164010000001281000000025511111111
00000000

0

00001111

15

01000000

64

10000000

128

11111111

255

Step 9 of 13Try the calculator

8-bit binary to decimal converter

Set each bit to 0 or 1, from the most significant bit (128) on the left to the least significant bit (1) on the right.

Decimal value
181
Even (0) or odd (1)
1

Step 10 of 13Note

Step 11 of 13Practice · True or false

Adding a 0 to the right end of the binary number 1011 gives a number that is twice as large.

Step 12 of 13Practice · Code challenge

Write toDecimal(bits), which takes a string of 0s and 1s such as "1101" and returns its decimal value as a number. Do it yourself with a loop rather than using parseInt.

Runs in a sandbox in your browser.
  • toDecimal("1101")
  • toDecimal("101101")
  • toDecimal("11111111")
  • toDecimal("0")
  • toDecimal("1")

Step 13 of 13Practice · Choose one

Which binary number equals 100 in decimal?