Is there a particular reason to do the test "by hand"? Timing tests suggest it is not much faster than just using `Fraction`:
```
from astropy.utils.compat.fractions import Fraction
p = 0.3333333333333333333333333333333
%timeit abs(p-Fraction(p).limit_denominator(10)) < 1.e-14
# 10000 loops, best of 3: 72.2 µs per loop
def testfrac(p):
    for i in [10,9,7,6]:
        scaled = p * float(i)
        if scaled % 1.0 < 1e-14:
           p = Fraction(int(scaled), i)
    return p

%timeit testfrac(p)
# 10000 loops, best of 3: 25 µs per loop
```

Also, at some level the power-of-two test duplicates what is done above. Would a reordering make sense? I.e., first do the work on floats and only then check whether `isinstance(p, Fraction)` and undo powers of 1,2,4,8? Not really important, but it may be a bit clearer/more concise.