80-Bus News

  

April–June 1982, Volume 1, Issue 2











Page 10 of 55











10

INPUTting and READing Double Precision Constants by Mike York

Some of the purchasers of my Double Precision Package (DPP) extension of the Nascom ROM BASIC (marketed by myself at 9 Rosehill Rd, London SW18 and also by Business & Leisure and the Microvalue group as "MathsPak") have pointed out that it does not support the INPUTing or READing of double precision constants. As things stand, double precision constants can only be entered as a numerical constant in an expression to be evaluated by a call to the DPP. This is inconvenient when it is required to enter a large quantity of double precision conctants. .

Although I now recognise this to have been an error on my part, it was originally a conscious decision to leave out INPUT and READ facilities as non-essential when trying to minimise the memory requirements of the package. I had intended that INPUT and READ could be implemented in BASIC rather than as part of the M/C package and thus would occupy no space when not required. However, the BASIC routane required is rather longer than I anticipated and it would probably, with hindsight, have been better to include it in the DPP from the start. Still, for those of you who wish to see such a routine, here it is: _

10 WIDTH 80

20 PRINT "FACILITY FOR INPUT OR READ OF A "; 30 PRINT “DOUBLE PRECISION FLOATING POINT "; AO PRINT "DECIMAL CONSTANT"

50 PRINT "INTO A VARIABLE."

60 PRINT "GET THE DECIMAL STRING INTO A$ "; 70 PRINT "(INPUT, READ OR WHATEVER) AND GOSUB "; 80 PRINT "2000."

90 PRINT "THE BINARY EQUIVALENT IS RETURNED"; 1400 PRINT " IN A$ READY FOR USE IN THE DPP.” 110 PRINT

1420 LINES 37:LIST 2000

2000 REM CONVERT ASCII DECIMAL TO DP BINARY 2010 XP=0:PT=-1:MH=0:LH=0:SN$=""

2020 K=0:D=0

2030 L=LEN(AS)

2040 K=K+1:IF K>L GOTO 2190

2050 DG$=MID$(A$,K,1)

2060 IF DG$="_" GOTO 2120 2070 IF DG$="+" OR DG$="-" GOTO 2160 2080 IF DG$="." GOTO 2110

2090 IF DG$="E" GOTO 2180 2100 GOTO 2040 : REM NEXT CHAR 2110 PT=K-1 : REM NOTE POSITION OF DECIMAL POINT 2120 REM DELETE DECIMAL POINT & BLANKS 2130 A$=LEFT$(A$,K-1)+RIGHTS (A$, L-K) 2140 K=K-1:GOTO 2030 2150 REM SAVE SIGN, DELETE IT AND LEADING BLANKS 2160 SN$=DG$:A$=RIGHTS(A$,L-K):GOTO 2020 2170 REM SPLIT MANTISSA AND EXPONENT 2180 XP=VAL(RIGHTS(A$,L-K)):A$=LEFT$(A$,K-1) 2190 K=K-1:IF PT<O THEN PT=K 2200 IF K<8 GOTO 2240 2210 IF K>14 THEN K=14:A$=LEFT$(A$,K) 2220 REM LH IS LEAST SIGNIFICANT HALF 2230 LH=VAL(RIGHTS (A$, K-7) )=BREI/ tot (K-7) 2240 IF K>7 THEN K=7 (continued elsewhere!)


This is an OCR’d version of the scanned page and likely contains recognition errors.











Page 10 of 55