supposing I have a decimal like $$ 0.30000000000000027$$
What would be the best way to know the same number but in a fraction way like we know $\dfrac{1}{3} > 0.30 > \dfrac{1}{4}$
because I think there must be an algorithm given certain $x$ find $y$ that satisfies $x=\frac{1}{y}$
Suppose you have an $x$ such that $x$'s decimal expansion goes like: $$ x=0.a_1a_2\ldots a_n $$ Where $a_1a_2\ldots a_n$ are digits base $10$.
Then $x$ is the rational number: $$ x= \frac{a_1a_2\ldots a_n}{10^n} $$ If $x$ has the form $$ x = \frac{1}{y} \;\;\; \text{for $y$ an integer} $$ Then $$ y = \frac{10^n}{a_1a_2\ldots a_n} \;\;\; \text{and is an integer} $$ Yielding: $$ x=\frac{1}{\frac{10^n}{a_1a_2\ldots a_n}} $$ If $x$ doesn't have the form $\frac{1}{y}$, use euclid's algorithm to compute the GCD of the numerator and the denominator, and then divide the numerator and the denominator by the GCD to put the fraction in lowest terms.