Sub topic 2
Writing Numbers in Base n
We assume that you can work with whole-number arithmetic, powers of 2, 3, and 10, and basic remainders. A base is the number of symbols available for writing values. Decimal uses base 10 and the digits 0 through 9. Base 5 uses only 0 through 4.
The value of a digit depends on its position. In any base \(b\), positions from right to left represent \(b^0, b^1, b^2,\ldots\). Therefore, a numeral is a sum of each digit multiplied by its place value.
For example:
\[ (314)_5=3(5^2)+1(5^1)+4(5^0) \]
\[ =3(25)+1(5)+4=84 \]
The subscript 5 says that 314 is written in base 5. Without the subscript, 314 normally means decimal.
| Position | Power in base 5 | Value |
|---|---|---|
| Units | \(5^0\) | 1 |
| Fives | \(5^1\) | 5 |
| Twenty-fives | \(5^2\) | 25 |
| One hundred twenty-fives | \(5^3\) | 125 |
The positional model
For a base-\(b\) numeral with digits \(d2d1d_0\),
\[ (d2d1d0)b=d2b^2+d1b+d_0 \]
The largest permitted digit is \(b-1\). Thus, a base 2 numeral has only 0 and 1. A base 8 numeral has digits 0 through 7. A base 16 numeral uses 0 through 9 and letters A through F, where A means 10 and F means 15.
The same value can have different written forms:
\[ (1011)_2=1(8)+0(4)+1(2)+1=11 \]
\[ (21)_5=2(5)+1=11 \]
The representations differ, but their decimal values match.
def from_base(digits, base):
value = 0
for ch in digits:
value = value * base + int(ch, 16)
return value
print(from_base("101101", 2)) # 45
print(from_base("213", 5)) # 58The code uses a running value. When it reads a new digit, it multiplies the current value by the base, making room for the new place, and then adds the digit.
A quick expansion method
To evaluate \((423)_6\), begin with the highest place:
\[ 4(6^2)+2(6^1)+3(6^0) =4(36)+2(6)+3 =159 \]
For CAT questions, write the powers beside the digits before calculating. This prevents the common error of treating the digits as ordinary decimal values without place values.
CAT strategy
When an equation contains a base-\(b\) numeral, expand it using powers of \(b\). Keep the base symbolic until the equation is formed. For instance, \((12)_b= b+2\), not 12. This often turns a digit problem into a simple algebra equation.
Exercise
Evaluate (132)_4 in decimal.
Show answer
Expand by place value: 1(4²) + 3(4) + 2 = 16 + 12 + 2 = 30.