01 Number and numeration
Number bases and modular arithmetic
Read this lesson
What you should be able to do
- Convert whole numbers and fractions between bases
- Work with remainders in modular arithmetic
Understand it
Place value depends on the base. In base b, places to the left of the point represent powers b⁰, b¹, b² and so on; places to the right represent b⁻¹, b⁻² and so on. Each digit must be smaller than the base.
To convert from base ten, divide the whole-number part repeatedly by the new base and read the remainders upwards. Convert a fractional part by repeated multiplication, reading the whole-number parts in order.
Working modulo n means comparing remainders after division by n. For example, 17 and 5 are congruent modulo 12. Perform ordinary addition or multiplication and then reduce the result to its remainder.
Work through an example
Convert 101.1₂ to base ten.
Explanation: 1×2² + 0×2¹ + 1×2⁰ + 1×2⁻¹ = 4 + 0 + 1 + 0.5 = 5.5.
Watch out: A base-two number cannot contain the digit 2.
2 practice questions with answers
Try each question before opening its answer. These are original CampusNinja practice questions.
Question 1
What is 1101₂ in base ten?
Show answer and explanation
Answer C: 13
Read the binary place values from right to left as 1, 2, 4 and 8. Then 1101₂ = (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1) = 13. The zero contributes nothing, but its place value must still be kept.
Question 2
What is 23 + 9 modulo 7?
Show answer and explanation
Answer D: 4
First add: 23 + 9 = 32. Divide by 7: 32 = (4 × 7) + 4, so the least non-negative remainder is 4. The quotient happens to be 4 as well in this example; modulo asks for the remainder, not the quotient.