DONAT STEMSciences and MathsENFR
Learn · Mathematics

How to convert a number to binary (and back)

A short explainer with a free virtual lab to try it yourself.

Short answerTo change a decimal number to binary, divide by 2 again and again and write down the remainders. Then read the remainders from the bottom up. For example, 45 = 101101 in base 2. To change back, add the place values 32, 16, 8, 4, 2 and 1 wherever there is a 1.

🧪 Try it in the free lab. In the free Binary lab you switch bits on and off, convert between bases, and use standard form for very large and very small numbers.

Open the lab →

Decimal to binary: repeated division

Convert 45 to base 2:

DivisionQuotientRemainder
45 ÷ 2221
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading the remainders from the bottom up: 45 = 101101₂.

Binary to decimal: place values

In base 2, the place values are powers of 2: 1, 2, 4, 8, 16, 32, 64, …

101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 8 + 4 + 1 = 45. The answer checks.

Adding in binary

The rules are 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1), and 1 + 1 + 1 = 11 (write 1, carry 1).

Example: 1011₂ + 110₂ = 10001₂. Check in decimal: 11 + 6 = 17 = 16 + 1.

Why computers use binary

A computer is built from millions of tiny switches (transistors) that are either off (0) or on (1). Two states are easy to make reliable. One binary digit is a bit; 8 bits make a byte, which can store 2⁸ = 256 different values, from 0 to 255.

Other bases

The same method works for any base: divide by 5 for base 5, by 8 for octal. Base 16 (hexadecimal) uses the digits 0–9 and the letters A–F, and is used for colour codes on websites: #102B46 is the navy blue of this site.

🧪 Binary lab: number bases, indices and standard form · free, works on any phone, with graphs, questions and a lab report.

Start the lab →

Questions people ask

Why read the remainders from the bottom up?

The first remainder is the units digit (2⁰), so it goes on the right; the last one is the highest place value.

What is the largest number with 4 bits?

1111₂ = 8 + 4 + 2 + 1 = 15, which is 2⁴ − 1.

Is 102 a binary number?

No. Binary uses only the digits 0 and 1.

Practise this topic

Written by BIZIYAREMYE Donat, Experienced Physics and STEM Educator, Rwanda. Published 30 November 2026. Found a mistake? Write on WhatsApp 0788 804 242. More explainers · All Interactive Labs