Lets say i want to turn a decimal number into a fractional number.
But the limit is that the combined number of digits of the numerator and denominator is restricted to some constant.

How can i work out what the most accurate representation of the decimal is, staying within the digit limits?