FIGURE HANDLING (1K ZX81)
By B M Hawkes, Budleigh Salterton, Devon
from Your Computer, November 1981, Page 74

Although Basic is a mathematically-orienated language, the versions on most
hobbyist micros suffer from excessive accuracy - the results are displayed
to far more significant figures than are required for most purposes. This
can be awkward when the results are to be tabulated, especially in such
micros as the ZX-81, where the number of characters per line is only 32.

Also, tabulation is normally left-justified, whereas it is neater to align
the decimal points. These subroutines are designed to carry out those
operations.

The first corrects a number of N significant figures, the second to N places
of decimals, and the third prints a number with the decimal point at a
specified tubulator position. In the first two, it is assumed that the
number is already held as A, and that N is also held. At the end of the
subroutine, A is corrected to the given accuracy. If the full value is
required also, a line such as LET B=A should be inserted beforehand.

In the third program, the number to be printed is again assumed to be held
in A, but the tabulator position X of the decimal point is inserted by an
Input statement in the subroutine, though it could equally well be inserted
by a Let or a Data statement if appropriate to the machine concerned.

Although the programs are written in ZX-81 Basic, the modifications likely
to be required for other dialects have been noted.

Lines 510-550 handle integers, 560-650 handle decimals with an integral
part, and 660-720 handle decimals less than one. The following modifications
are likely to be needed for other dialects of Basic.

Line 580: IF ASC(MID$(A$,X,1))=46 THEN GOTO 610
Line 670: IF ASC(MID$(A$,Y,1))>47 THEN GOTO 700

Also many Basics use "up arrow" for exponentiation where Sinclair uses two
asterisks, so this may need to be altered, and in some Basics storage space
could be saved by omitting Let, etc.

The third subroutine should run with any Basic dialect except, of course,
integer Basics.
