Case I: Finite Decimal
Suppose that the decimal is $$.a_1a_2\ldots a_n$$ Then by definition of that notation, the number can be written $$\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots+\frac{a_n}{10^n}$$ You can then combine the fractions and reduce.
Example. $$.18=\frac{18}{100}=\frac{9}{50}$$
Case II: Infinite Repeating Decimal
We already know that the first (finite) non-repeating component may be written as a decimal per the algorithm above. For the repeating part $$.00\ldots 0a_1a_2\ldots a_na_1\ldots a_n\cdots$$ which the sequence $a_1\ldots a_n$ repeated infinitely, we have by the formula $$a+ar+ar^2+\cdots=\frac{a}{1-r}\qquad (|r|<1)$$ that, if there are $m$ zeros initially, $$\begin{align}.0\ldots 0\overline{a_1\ldots a_n}&=\frac{a_1\ldots a_n}{10^{m+n}}+\frac{a_1\ldots a_n}{10^{m+2n}}+\cdots \\ &=\frac{a_1\ldots a_n}{10^{m+n}}\left(1+10^{-n}+10^{-2n}+\cdots\right) \\ &=\frac{a_1\ldots a_n}{10^{m+n}}\left(\frac{1}{1-10^{-n}}\right)\end{align}$$
Example. $$0.333\ldots=\frac{3}{10}\left(1+\frac{1}{10}+\frac{1}{10^2}+\cdots\right)=\frac{3}{10}\left(\frac{1}{1-10^{-1}}\right)=\frac{3}{10-1}=\frac{1}{3}$$
Case III: Infinite Non-Repeating Decimal
These types of numbers are called irrational, and cannot be written as fractions of integers (for example, $\sqrt 2$ has no fractional expression).
However, they can be approximated by fractions to any degree of accuracy needed. A straightforward algorithm for doing this is provided by the theory of the Stern-Brocot tree. It provides the "simplest" approximation which starts with the correct $n$ decimal places.
Example. The decimal expansion of $\pi$ (an irrational number) begins $3.141592653589793\ldots$. Using a computer program, I find that the first few best rational approximations for the decimal part $.141592653589793\ldots$ are $$\begin{align}{1 \over 7} &=0.142... \\ {9 \over 64} &=0.1406... \\ {15\over 106} &=0.14150... \\ {16\over 113}&=0.1415929... \\ &\;\vdots \\ {3612111\over 25510582}&=0.14159265358979267...\end{align}$$
It's useful in everyday life. Most people will only ever come across fractions when dividing objects between groups, and then it is useful. For example, if you have to split 16 things between 5 people you do $\frac{16}{5} = 3\frac{1}{5}$ and you know you'll have three each plus one left over. This is much easier (and practically more useful) than actually doing the division to find the decimal expansion of $\frac{16}{5} = 3.2$.
Best Answer
You can do that by simply putting a bar on top of the decimal digits that repeat, for example, $\frac{1}{7} = 0.142857142857142857...$ which you can write $0.\overline{142857}$.
It's even better to write fractions like $\frac{3}{44} = 0.06\overline{81}$ which have repeating digits that don't start immediately after the dot.
You can find some other ways to write fractions on this website if you want (in section 1.4).