Sub topic 8
Fractional parts in other bases
This chapter extends place value to the right of the point. It assumes you can already convert integers between decimal and base n, and that you can do basic fraction arithmetic and prime factorisation. The questions you will meet are: convert a "base-n decimal", decide whether a fraction terminates, and find an unknown base from a repeating expansion. This topic has a low weight in CAT, but each question type is short once you know the rule.
Place value after the point
In base b, the digits to the right of the point carry weights b⁻¹, b⁻², b⁻³ and so on. In base 10 these are tenths, hundredths and thousandths. In base 2 they are halves, quarters and eighths.
So 0.d₁d₂d₃ in base b equals d₁/b + d₂/b² + d₃/b³.
A full number such as 12.34 in base 5 splits into an integer part and a fractional part:
- Integer part: 1·5 + 2 = 7.
- Fractional part: 3/5 + 4/25 = 15/25 + 4/25 = 19/25.
- Total: 7 + 19/25 = 7.76 in decimal.
A quick way to avoid fractions in the working: write the digits after the point as one integer and divide by b raised to the number of digits. Here "34" in base 5 is 3·5 + 4 = 19, and b² = 25, which gives 19/25 again.
Decimal fraction to base n: repeated multiplication
Integers convert by repeated division and reading remainders upward. Fractions convert by the mirror procedure:
- Multiply the fraction by the base.
- The integer part of the product is the next digit.
- Keep only the fractional part and repeat.
- Stop when the fractional part is 0, or when a fractional part repeats.
Reading the digits from first to last gives the numeral. The first digit comes out first, which is the opposite order from integer conversion.
Example: write 0.375 in binary.
| Step | Fraction × 2 | Digit | Remaining fraction |
|---|---|---|---|
| 1 | 0.75 | 0 | 0.75 |
| 2 | 1.5 | 1 | 0.5 |
| 3 | 1.0 | 1 | 0 |
The result is 0.011 in base 2. Check: 1/4 + 1/8 = 3/8 = 0.375.
For a number with both parts, convert the integer part by division and the fractional part by multiplication, then join them at the point.
Grouping works on both sides of the point
The grouping shortcut for binary, octal and hexadecimal also works for fractions. Group bits in threes for octal and in fours for hexadecimal. Start at the point and move outwards. To the right of the point, pad with zeros on the right, not the left.
Take 0.1011 in binary:
- Hexadecimal: the group 1011 is B, so the value is 0.B in base 16.
- Octal: the groups are 101 and 100 (padded), giving 5 and 4, so the value is 0.54 in base 8.
Check: 0.1011₂ = 1/2 + 1/8 + 1/16 = 11/16. Also 0.B₁₆ = 11/16, and 0.54₈ = 5/8 + 4/64 = 44/64 = 11/16.
When does a fraction terminate?
Write a fraction p/q in lowest terms. It terminates in base b exactly when every prime factor of q is also a prime factor of b.
The reason is that a terminating expansion with k digits equals N/bᵏ for some integer N. So q must divide bᵏ for some k, and that forces every prime of q to appear in b.
| Fraction | Base | Terminates? | Reason |
|---|---|---|---|
| 7/20 | 10 | Yes | 20 = 2²·5, and both 2 and 5 divide 10 |
| 7/20 | 6 | No | 5 does not divide 6 |
| 3/8 | 6 | Yes | 8 = 2³, and 2 divides 6 |
| 1/10 | 2 | No | 5 does not divide 2 |
| 1/3 | 3 | Yes | 3 divides 3, so 1/3 = 0.1 in base 3 |
| 1/12 | 7 | No | 2 and 3 do not divide 7 |
The number of digits after the point is the smallest k with q dividing bᵏ. For 3/8 in base 6, 6² = 36 is not a multiple of 8, but 6³ = 216 = 8·27 is. So there are 3 digits. Check by multiplying:
- 3/8 × 6 = 2.25, so the digit is 2 and 0.25 remains.
- 0.25 × 6 = 1.5, so the digit is 1 and 0.5 remains.
- 0.5 × 6 = 3, so the digit is 3 and nothing remains.
This gives 0.213 in base 6. Verify: 81/216 = 3/8.
Repeating expansions back to fractions
In decimal, 0.(3) means 0.333... and equals 3/9. The same pattern holds in every base. A block of k repeating digits, read as an integer N in base b, gives the fraction N/(bᵏ − 1).
- A single repeating digit d: 0.(d) = d/(b − 1). So 0.(1) in base 2 is 1/1 = 1, and 0.(4) in base 5 is 4/4 = 1.
- Two repeating digits: 0.(12) in base 5 has N = 1·5 + 2 = 7 and bᵏ − 1 = 24, so the value is 7/24.
- Alternating bits: 0.(01) in base 2 has N = 1 and bᵏ − 1 = 3, so the value is 1/3.
When some digits come before the repeating block, split the number. Take 0.1(01) in base 2. The leading digit contributes 1/2. The repeating part starts one place later, so it contributes (1/3)/2 = 1/6. The total is 1/2 + 1/6 = 2/3. This matches the binary expansion 0.101010... of 2/3.
The "digit is b − 1" case explains an effect that surprises learners. In base b, 0.(b−1) equals 1, exactly as 0.999... equals 1 in decimal.
Solving for an unknown base
Repeating-digit formulas turn base-finding questions into one equation.
Example: in base b, 0.(2) equals 1/4. Find b.
- Use 0.(2) = 2/(b − 1).
- Set 2/(b − 1) = 1/4, so b − 1 = 8 and b = 9.
- Check: 2 is a valid digit in base 9, and 2/8 = 1/4.
Example: in base b, 0.4 (terminating) equals 1/2. Then 4/b = 1/2, so b = 8.
Always check that every digit in the problem is smaller than the base you find.
Checking by computer
The following program converts a fraction in [0, 1) to base n by repeated multiplication. It uses exact Fraction arithmetic, so it detects a repeating block when a remainder reappears. It marks the repeating part in parentheses.
from fractions import Fraction
SYMBOLS = "0123456789ABCDEF"
def frac_to_base(x, base):
seen = {}
digits = []
while x != 0 and x not in seen:
seen[x] = len(digits)
x *= base
d = int(x)
digits.append(SYMBOLS[d])
x -= d
if not digits:
return "0.0"
if x == 0:
return "0." + "".join(digits)
start = seen[x]
return "0." + "".join(digits[:start]) + "(" + "".join(digits[start:]) + ")"
def terminating_to_fraction(digits, base):
return Fraction(int(digits, base), base ** len(digits))
def repeating_to_fraction(block, base):
return Fraction(int(block, base), base ** len(block) - 1)
print(frac_to_base(Fraction(3, 8), 6)) # 0.213
print(frac_to_base(Fraction(1, 10), 2)) # 0.0(0011)
print(frac_to_base(Fraction(1, 3), 2)) # 0.(01)
print(terminating_to_fraction("213", 6)) # 3/8
print(repeating_to_fraction("12", 5)) # 7/24
print(repeating_to_fraction("01", 2)) # 1/3The line 0.0(0011) shows why 0.1 cannot be stored exactly in binary: 1/10 has a factor 5, which does not divide 2.
Common errors
- Reading the digits in the wrong order. For fractions, the first multiplication gives the first digit after the point.
- Forgetting to reduce first. 6/16 reduces to 3/8, and only the reduced denominator matters for the termination test.
- Treating a repeating block as a terminating one. The expansion 0.(01) in base 2 is 1/3, not 1/4.
- Using b − 1 when the block has several digits. The divisor is bᵏ − 1, where k is the block length.
- Padding on the wrong side when grouping bits after the point.
Exercise
Convert 0.121 in base 3 to a fraction in decimal.
Show answer
The digits give 1/3 + 2/9 + 1/27 = 9/27 + 6/27 + 1/27 = 16/27. Equivalently, "121" in base 3 is 1·9 + 2·3 + 1 = 16, and 3³ = 27, so the value is 16/27.
Exercise
Does 1/12 terminate in base 7? Does it terminate in base 6? If it terminates in base 6, how many digits does it have?
Show answer
In base 7 it does not terminate, because 12 = 2²·3 and neither 2 nor 3 divides 7. In base 6 it terminates, because both 2 and 3 divide 6. The smallest k with 12 dividing 6ᵏ is k = 2, since 36 = 12·3. So it has 2 digits: 1/12 = 3/36 = 0.03 in base 6.
Exercise
In base b, the repeating decimal 0.(3) equals 3/8. Find b.
Show answer
Use 0.(3) = 3/(b − 1). Setting 3/(b − 1) = 3/8 gives b − 1 = 8, so b = 9. The digit 3 is valid in base 9, and 3/8 matches the given value.