Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Binary, Hex and Endianness  ›  Lesson

Binary — Place Value in Powers of Two

Endianess 12 minBinary writes numbers with only the digits 0 and 1, where each position is worth twice the position to its right.

Binary — Place Value in Powers of Two

Deep down, a computer stores everything as switches that are either off or on. To store the number 13, it needs a way to write 13 using only two symbols. The answer is the same place-value idea you already use for decimal, with one change: each place is worth double the one to its right instead of ten times.

The rule

Each bit is worth double the bit on its right.

A bit is one binary digit: 0 or 1. Reading from the right, the places are worth 1, 2, 4, 8, 16, 32, 64, 128 and so on. A 1 means "include this value"; a 0 means "skip it".

place value:  8  4  2  1
bits:         1  0  1  1
              8 +0 +2 +1  = 11

So binary 1011 is decimal 11. Programmers often write 0b1011 to make the base clear.

Eight bits make a byte. With n bits there are 2ⁿ different patterns, so a byte holds 2⁸ = 256 patterns, the numbers 0 to 255. The largest value with n bits is always 2ⁿ − 1, all ones: 11111111 = 255.

The shortcut

Binary to decimal: add up the place values sitting under the 1s.

Decimal to binary: take the biggest power of two that fits, subtract, and repeat with what is left. Every power you take becomes a 1; every one you skip becomes a 0.

Converting 25 to binaryStep 1 of 4
  1. Biggest power that fits

    16 fits into 25 and 32 does not. Take 16: 9 left.

The trap is reading binary like decimal. 10 in binary is two, not ten, and 100 is four. Always read the places, never the digits as a whole.

Drills

Answer fast — trust the rule.

quick drill

What is binary 10110 in decimal?

quick drill

What is 13 in binary?

quick drill

What is the largest number one byte (8 bits) can hold without a sign?

quick drill

How many different values can 10 bits represent?

Remember

  • Each bit is worth double the one to its right: 1, 2, 4, 8, 16, …
  • To convert, add the place values under the 1s, or peel off the biggest powers of two.
  • The trap: n bits hold 2ⁿ values, but the biggest is 2ⁿ − 1.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainTo binary and back

Convert 45 into binary and convert 110010 back into decimal, showing your method. Then explain how many different values 8 bits can hold and what the largest one is.