Start with a/b and find the quotient q and remainder r. Write down the quotient, the integer part of the number. Then multiply r by 10 and divide by b, giving a new q and r. Record the value of q, the first decimal digit. Then multiply r by 10 and divide by b, giving a new q and r. Record the value of q, the second decimal digit. Repeat this process, building a monotonically increasing sequence of decimal approximations to a/b.
After the jth step, the remainder is rj, between 0 and b, and the precision is 10-j. In other words, the difference between the jth approximation and a/b is less than b/10j. The error term goes to 0, and the sequence approaches a/b. When viewed as a real number, the sequence equals a/b.
Since each remainder is between 0 and b, rj eventually duplicates an earlier ri. At this point we are stuck in an infinite loop. If rj = ri = 0, the decimal is terminating. There is no need to write down all the zeros. If rj is not zero the decimal is repeating. For example, 97/22 = 4.40909090909…
Conversely, a terminating or repeating decimal is equal to a rational. Clearly 4.409 = 4409/1000. If the decimal repeats, such as 4.40909090909…, write it as the sum 4.4 + 0.00909090909…, which is 44/10 + one tenth of 9/99. If the repeating block contains three digits, the denominator will be 999, and so on.
The correspondence between rationals and decimals is almost 1-1, but not quite. The numbers 3.699999… and 3.700000… are equivalent. The difference between successive approximations is 10-j, hence the difference sequence approaches 0.
Realize that every decimal representation is Cauchy. After the jth digit, the rest of the sequence is trapped within an interval of size 10-j. Decimal numbers always represent real numbers.
Some "describable" decimals are not rational. Consider the decimal whose jth digit is 1 if j is prime; otherwise the jth digit is 0. This is a valid formula, giving a Cauchy sequence that approaches a real number. The sequence doesn't terminate, as there are infinitely many primes, and it doesn't repeat, as there are arbitrarily large gaps between primes.
Suppose the decimals s and t represent the same real number. We've already discussed the .x99999… .y00000… equivalence, where y = x+1, so if either s or t has a tail of all nines, replace it with a tail of all zeros and increment the prior digit. Now let j be the first decimal digit where s and t disagree. Let t be larger than s, hence tj exceeds sj. The tail of s is not all nines, so let sk be something other than 9, for k > j. If sk is 7, for instance, s is trapped between 0.14997 and 0.14998, while t is at least 0.15000. Thus s and t cannot be equal. Setting the 99999… tails aside, rationals and terminating/repeating decimals correspond 1-1, and all other decimals map 1-1 into the irrationals.
But is every irrational represented by a decimal? Let s be irrational and perform long division as we did before. Subtract the largest integer from s, such that the remainder is not negative. Multiply by ten and subtract the largest integer, such that s is not negative. This is the first decimal digit. Multiply by ten and subtract the largest integer, such that s is not negative. This is the second decimal digit. Repeat this forever. An inductive argument shows the jth approximation, and all subsequent approximations, are within 10-j of s. The difference sequence between s and our constructed decimal approaches 0, hence the two sequences are equivalent. An irrational is uniquely determined by its decimal expansion.