Is there a function for turning any number $x$ into a fraction with a denominator that has a maximum of $k$ digits? (I'm sure there is, since Excel has one built in, I just can't figure out what it is.)
For example, $f(0.1234) = $
- $\frac{106}{859}$ where $k=3$;
- $\frac{10}{81}$ where $k=2$;
- $\frac{1}{8}$ where $k=1$.