Skip to content
Tactiverge

Digital logic

Binary place value

Also called: binary numbers · base 2 · binary to decimal · decimal to binary

Definition

In binary each digit position is worth twice the one to its right: 1, 2, 4, 8, 16 and so on. A number's value is the sum of the place values that hold a 1.

Picture it

It is the same idea as decimal place value with 2 instead of 10. To convert decimal to binary, repeatedly take off the biggest power of two that fits, or keep dividing by 2 and read the remainders from the bottom up.

The maths

value = Σ b_i × 2^i (i = 0 for the rightmost bit)
SI units used in this entry
QuantityUnitSymbol
informationbitbit
ratiodimensionless1

Worked example

Convert 1011 0110 (binary) to decimal, and 45 (decimal) to binary.

  1. 128 + 32 + 16 + 4 + 2 = 182
  2. 45 = 32 + 8 + 4 + 1 → 101101

Answer1011 0110 = 182; 45 = 101101.

✓ The 2 numbers in this answer are recomputed from scratch by an automated test.

flip the bits

Binary, decimal and hex

Unsigned: 182 · Two's complement: -74 · Hex: 0xB6

Unsigned and two's-complement readings of the same bit pattern. Python ints are unbounded; microcontroller registers are not.

Common misconceptions

  • Misconception: Binary 10 is two, not ten.
  • Misconception: Leading zeros do not change the value, but they matter when a field has a fixed width.