It comes as no surprise that computers can perform numerical calculations. For example, most computers will allow you to type in:
PRINT 29*173
and the result 5017 will be printed. However, there are some distinct limitations to the calculations that the computer can perform unaided. For example, suppose we type:
PRINT 1/2 + 1/3
The computer will probably print 0.833333 (or even less helpfully, 0) rather than the answer we would like, namely 5/6.
Alternatively, suppose we type in:
PRINT (X-1)*(X*X+X+1)
the result will depend on the particular value of X; a more useful answer would be the simplified form of the expression, X^3-1 (where "^" means "raised to the power").
Finally, suppose we enter:
PRINT 9999*9999*9999
desiring the exact answer 999700029999. In fact we will get 9.99700030E11 on the BBC Computer, or the less obvious answer 1120133679 on the Atom.
The three programs in this chapter solve these problems, and illustrate some of the different ways of representing numbers on a computer.