I wrote a program a long time ago that estimates a decimal value using an integer fraction. It works on the following principle: if you invert the fraction, then you are left with an expression of the form 1/x, where x is the *inverse* of the fraction. Furthermore, if you take away the integer part of the fraction, then you are left with another fraction to compensate for, so x is of the form (a + y), where a is the integer part and y is the compensation for the fractional part. You can then repeat with 'y' and end up with an expression of the form:
[tt]
0 + 1
-------------------
5 + 1
-------------
2 + 1
-----
...
[/tt]
(for the fraction 0.18723 -- this approximation yields 0.1875 after 4 levels, the above fraction simplifying to 3/16). This nested fraction is easy to convert back to a simple fraction: you simply start with the deepest nesting, incorporate the integer part into the fraction, then "invert and multiply" to do the division. The result is one less level with the same structure.
Here is the program itself:
[tt]
DIM intPart%(20)
fraction# = .1835718238#
levels% = 10
FOR i% = 1
TO levels%
compensation%(i%) =
INT(fraction# + .00001#)
IF ABS(intPart%(i%) - fraction#) < .00001
THEN
levels% = i%
EXIT FOR
END IF
fraction# = 1# / (fraction# - intPart%(i%))
NEXT i%
numerator& = intPart%(levels%)
denominator& = 1&
FOR i% = levels% - 1
TO 1
STEP -1
temp& = numerator&
numerator& = intPart%(i%) * numerator& + denominator&
denominator& = temp&
NEXT i%
dashes& =
INT(
LOG(denominator&) /
LOG(10)) + 4
format$ =
RIGHT$(
SPACE$(17) +
STRING$(dashes&, "-"

, 17) + " = #.############"
PRINT USING " ###,###,###,###"; numerator&
PRINT USING format$;
CDBL(numerator&) / denominator&
PRINT USING " ###,###,###,###"; denominator&
[/tt]