[Math] How to add, subtract, multiply, and divide infinite decimals

algorithmsarithmeticcalculusdecimal-expansionreal numbers

In elementary school, we are taught how to add, subtract, multiply, and divide two terminating decimals. My question is, what are the corresponding algorithms in the case of non-terminating decimals, whether repeating or otherwise?

Clearly such algorithms exists. For each natural number $n$, you can truncate the two decimals after $n$ decimal places, then apply the usual algorithms for terminating decimals, then take the limit as $n$ goes to $\infty$. (This works because addition, subtraction, multiplication, and division are continuous functions, and the truncation of a decimal after $n$ decimal places converges to the original decimal as $n$ goes to $\infty$.) But without taking limits, is there an elementary way to do it?

It's fine if the algorithms run forever. After all, even the long division algorithm to divide two natural numbers can run forever.

Best Answer

To add two infinite decimals, I'd begin by setting aside an infinite amount of time, since I'd need that long just to read the input.

For a more reasonable algorithmic problem, suppose I just want to compute the first significant digit of the sum; maybe that won't require reading the whole input. Unfortunately, in some cases, it does. Suppose I want to add $0.9999\dots$ and $0.0000\dots$. If the "$\dots$" means all $9$'s in the first case and all $0$'s in the second, then the sum is $1$, and there are two correct ways to write the answer, $1.000\dots$ and $0.9999\dots$, so the digit just to the left of the decimal point could be $1$ or $0$. But suppose the $\dots$ in the input weren't so simple; maybe the first one has an $8$ after a few million $9$'s while the second is (for simplicity) still all $0$'s. Then the digit just to the left of the decimal point of the answer has to be $0$ not $1$. On the other hand, if the first input has all $9$'s but the second has a $1$ after a few million $0$'s, then the digit just to the left of the decimal point of the answer has to be $1$, not $0$. So, to figure out the digit just to the left of the decimal point in the answer, you might need to read millions of digits of the input.

Maybe you're patient enough to read millions of digits, but the situation can be even worse. If the inputs really are all $9$'s and all $0$'s after the decimal point, so either $1$ or $0$ could be digit just to the left of the decimal point, you can't actually give either of those (correct) answers after any finite amount of time. Even after reading millions of boring $9$'s and $0$'s, you'd still have the possibility that the first input could eventually have an $8$ or the second input could eventually have a $1$, making one of the two possible digits just to the left of the decimal point incorrect. So you could never confidently output the digit just to the left of the decimal point of the answer.

The moral of this story is that addition of infinite decimals is unpleasant in any situation where you want accurate algorithms.