Level 0 · Module 1
Binary numbers
Read and write base-two numbers using place values.
Not completed
By the end, you can
- Identify binary place values.
- Convert small binary values to decimal.
- Convert a small decimal value to binary.
Summary
Binary is a way to write numbers using only 0 and 1. Each position stands for a power of two, so 10110₂ means 16 + 4 + 2, which is decimal 22.
Introduction
You already use place values in decimal: the digits in 347 mean three hundreds, four tens, and seven ones. Binary follows the same idea, but its places are ones, twos, fours, eights, and so on.
Explanation
Write the place values from right to left: 1, 2, 4, 8, 16, .... A 1 means “include this value”; a 0 means “do not include it.” To turn a decimal number into binary, first choose the largest place value that does not exceed the number. Subtract it, then repeat with smaller places.
Real-world example
A compact settings value can use one bit for each option. The pattern 101 can mean the first and
third options are on while the second is off.
Read every column
Interactive exploration
Binary number
Step 1 of 8
To turn 22 into binary, start with 16. It fits, leaving 6. Next, 8 does not fit, so write 0. Then 4 fits, leaving 2; 2 fits, leaving 0; and 1 does not fit. The included places make 10110.
Code example
const decimal = 22;
console.log(decimal.toString(2)); // 10110
console.log(Number.parseInt('10110', 2)); // 22Common mistakes
- Reading
10110as “ten thousand one hundred ten”; it is not decimal. - Starting binary place values at two instead of one.
- Treating the base marker in
10110₂as another digit.
Quiz
Knowledge check
Try it
Convert both ways
Convert decimal 19 to binary, then verify by adding its binary place values.
Key takeaways
- Binary positions are powers of two.
- A
1includes a place value and a0excludes it. - Conversion works in both directions using place values.