Numeration in base b
Writing an integer in any base: successive divisions, Horner's scheme, number of digits, the largest integer with n digits and column addition.
- 23 cards
- 5 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- The numbers
- Scenarios
A few cards from the deck
Base-b representation: what is it?
Show the answer
The representation aₙ…a₁a₀ of an integer N = aₙbⁿ + … + a₁b + a₀, where each digit aᵢ lies between 0 and b − 1; it exists and is unique.
Uniqueness comes from Euclidean division: (2102)₃ = 2 × 27 + 1 × 9 + 0 × 3 + 2 = 65. A digit equal to or above b cannot appear.
What does this program print?
```python
n, b, chiffres = 100, 6, []
while n:
n, r = divmod(n, b)
chiffres.append(r)
print(chiffres)`[4, 4, 2][2, 4, 4][16, 2, 0][1, 4, 4]
Show the answer
[4, 4, 2]100 = 6 × 16 + 4, 16 = 6 × 2 + 4, 2 = 6 × 0 + 2: the list receives the remainders in the order they come out, from weight 1 to weight 36. Reverse it to read (244)₆.
In base b, the digits run from 0 to …, and the largest integer that can be written with n digits is ….
Show the answer
In base b, the digits run from 0 to b − 1, and the largest integer that can be written with n digits is bⁿ − 1.
In base 10 with three digits, 999 = 10³ − 1; in base 2 with 8 bits, 255 = 2⁸ − 1. There are bⁿ possible representations, from 0 to bⁿ − 1.
Weight of a digit: what is it?
Show the answer
The power of the base by which a digit is multiplied according to its position: bⁱ for the digit at rank i counting from the right, starting at 0.
In base 5, the weights are 1, 5, 25, 125…: in (431)₅, the 4 weighs 25, which is 100. The digit of weight 1 is the last one, on the right.