Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you have a number _x_ of the form:
- a.bc
- Where `a` is the integer part, `b` is the non-repeating fractional part, and `c` is the repeating fractional part, then the resulting fraction has value:
- a.b + c / ((10^num_digits(c) - 1) * 10^num_digits(b))
- So for 0.333333... we have:
- a = 0
- b = 0
- c = 3
- Giving:
- 0.0 + 3 / ((10^1 - 1) * 10^0)
- 1 / 3
- The more complex .20151515151515... we have:
- a = 0
- b = 20
- c = 15
- Giving:
- 0.20 + 15 / ((10^2 - 1) * 10^2)
- 133 / 660
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement