The TS 1000/1500 computers (and many others) do calculations to 9 or 10 significant figures. As described at the end of Chapter 4 in the TS 1000 manual, the ROM’s floating point arithmetic uses a 32 bit mantissa for a decimal accuracy of 32 * LN 2/LN 10 which equals 9.63 digits. However, in order to limit printout to 14 Spaces, only 8 significant places are printed.
For my engineering work, I often prefer to see all ten figures the computer is using rather than the rounded eight places normally printed. The main purpose of this article is to present the subroutine (line 1000) used to print numerical variables rounded to ten significant places in scientific notation in lieu of using the TS 1000 ROM routine which rounds to eight places and uses scientific notation only if Nis as described in line 1052. aA secondary purpose is to present a subroutine (line 1050) which ‘normalizes’ the variable to scientific notation regardless of its magnitude.
Lines 5 to 35 contain a small sample program which uses the Ten Place subroutine repeatedly to evaluate formulas comprised of numbers, previously defined variables and functions. Line 2000 is useful for determining the size of the variable area.
As shown, the program prints five lines to the screen, asks for the formula and repeats it, gives the variable and the variable minus it’s seve most significant digits in scientific notation (after gaining confidence in the program, this should be eliminated by deleting line 1072), prints variable in normal fashion (eliminated by deleting first part of line 1024), and the variable to ten places in scientific notation.
This programming exercise was used in a presentation of a project aimed at developing a double precision TS 1000/1500 subroutine.
Products
Media
Image Gallery
Source Code
5 REM TEN PLACE ACCURACY
7 REM BY DONALD L. DEAN
10 PRINT " INPUT F$ ";
15 INPUT F$
20 PRINT F$
25 LET N=VAL F$
30 GOSUB 1000
33 PRINT
35 GOTO 10
1000 REM PRINT 10 PLACES
1002 GOSUB 1250
1004 FOR J=2 TO LEN N$
1006 IF N$ (J)<>"E" THEN NEXT J
1007 IF JC=3 THEN GOTO 1024
1008 LET N$=N$( TO J-2) +N$ (J TO )
1010 LET M=ABS N-ABS VAL N$
1012 LET V=N
1014 LET V$=N$
1016 LET N=M
1018 GOSUB 1050
1020 LET N=V
1022 LET N$=V$( TO J-2)+STR$ ‹ INT (100*VAL N$ ( TO 5)+.5)) +V$(J-1 TO )
1024 PRINT "N=": N,, "N$=": N$
1026 RETURN
1049 STOP
1050 REM NORMALIZE
1052 IF ABS N<=1E-6 OR ABS N>=1E 13 THEN GOTO 1070
1054 IF ABS N>=1 THEN GOTO 1062
1056 FOR I=1 TO 5
1057 IF ABS N*10**I<1 THEN NEXT I
1059 LET N$=STR$ (N*10**I)+"E-"+ STR$ I
1060 GOTO 1072
1062 FOR I=0 TO 12
1064 IF ABS N/10**I>=10 THEN NEXT I
1066 LET N$=STR$ (N/10**I) +"E"+ STR$ I
1068 GOTO 1072
1070 LET N$=STR$ N
1072 PRINT "N$ (LOOP) ="; N$
1073 RETURN
2000 PRINT "VARIABLES AT "; PEEK 16400+256*PEEK 16401; " TO ": PEEK 16404+256*PЕEK 16405
2005 RETURN