Suppose I have been given a rational number in decimal format (since decimals of rationals repeat, finite precision presentation suffices), what is the most effective way to write it in form of ratio of integers $P/Q$?
I can think of checking if decimal is greater than $1$. If so, truncate decimal portion and invert it. This will again be decimal. So truncate and invert and repeat. Procedure should terminate. Group all terms in expansion to get needed ratio $P/Q$. Is there a better procedure to obtain the needed conversion?