Binary by Repeated Halving

Category: Number Theory   Level: 101

13 → 11012: divide by 2, keep remainders, read bottom to top

Divide by 2 again and again and write down each remainder. The remainders, read from the bottom up, are the binary digits.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Divide by 2, keep the remainder

13 ÷ 2 = 6 remainder 1. An odd number always leaves remainder 1, and that 1 is the last binary digit.

13 = 2 × 6 + 1

Step 1: Divide by 2, keep the remainder

Step 2: Pass the quotient down

Divide the quotient again: 6 ÷ 2 = 3 remainder 0. Each new remainder is the next place to the left.

6 = 2 × 3 + 0

Step 2: Pass the quotient down

Step 3: Repeat until the quotient is 0

3 ÷ 2 = 1 R 1, then 1 ÷ 2 = 0 R 1. A quotient of 0 means stop.

3 = 2 × 1 + 1, 1 = 2 × 0 + 1

Step 3: Repeat until the quotient is 0

Step 4: Read the remainders bottom to top

The last remainder is the biggest place. Read up the column to get 1101. Same answer as filling places with 8, 4, 2, 1.

13 = 11012

Step 4: Read the remainders bottom to top

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render binary-by-halving --out /tmp/binary-by-halving

Source: svgmath/diagrams/binary.py