Advertisement
Guest User

Untitled

a guest
May 27th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. If you have a number _x_ of the form:
  2.  
  3. a.bc
  4.  
  5. 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:
  6.  
  7. a.b + c / ((10^num_digits(c) - 1) * 10^num_digits(b))
  8.  
  9. So for 0.333333... we have:
  10.  
  11. a = 0
  12. b = 0
  13. c = 3
  14.  
  15. Giving:
  16.  
  17. 0.0 + 3 / ((10^1 - 1) * 10^0)
  18. 1 / 3
  19.  
  20. The more complex .20151515151515... we have:
  21.  
  22. a = 0
  23. b = 20
  24. c = 15
  25.  
  26. Giving:
  27.  
  28. 0.20 + 15 / ((10^2 - 1) * 10^2)
  29. 133 / 660
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement