If we want to turn a proper fraction $\frac{a}{b}$ into a decimal, then when $b$ is coprime to 10 we just need to rewrite $\frac{a}{b}$ in the form $$\frac{m}{10^{\phi(b)}-1}$$ where $\phi$ is Euler's totient function. And then the repeatend is $m$ and the period of repetition is $\phi(b)$. (This follows from Fermat's Little Theorem.)
But my question is, what do we do when $b$ is not coprime to 10? In that case we would need to rewrite $\frac{a}{b}$ in the form $$\frac{k + \frac{l}{m}}{10^n}$$ where $k < 10^n$, $\frac{l}{m}$ is a proper fraction, and $m$ is coprime to 10. Then $k$ would be the non-repeating part, $n$ would be the length of the nonrepeating part, and we can convert $l/m$ into a decimal using the procedure given in the beginning of my post.
But is there a formula for the four numbers $k$, $l$, $m$, and $n$ in terms of $a$ and $b$, short of doing long division to convert the fraction into a decimal?