My impl is just a few lines. I haven't tested it extensively, though.
EDIT:
Also, it doesn't need the gcd. It seems to be related to continued fractions, but is not really the same thing. I think...
Type: Posts; User: oogabooga
My impl is just a few lines. I haven't tested it extensively, though.
EDIT:
Also, it doesn't need the gcd. It seems to be related to continued fractions, but is not really the same thing. I think...
I ended up reading the wikipedia link you gave, but not until after I posted. I realized that it was the same idea!
That technique still needs to be applied in a case like 2/15:
0.1333333333333333333
So you could consider the first 0 in .1520000000 as being the repeating part.
You may end up needing some big...
An irrational ("not a ratio") number is one that cannot be written as a fraction, so there are no irrational fractions.
To figure out an algorithm, figure out how you would do it yourself.