5 REM - BASIC VERSION OF MACHAR 10 DEFINT I-N 20 DEFSNG A-H,O-Z 30 REM- DEFDBL A-H,O-Z 40 ONE=CSNG(1) 50 REM- ONE=CDBL(1) 60 ZERO=0! 70 REM-ZERO=0.0D0 80 A=ONE 90 A=A+A 100 IF (((A+ONE)-A)-ONE = ZERO) GOTO 90 110 B=ONE 120 B=B+B 130 IF ((A+B)-A = ZERO) GOTO 120 140 IBETA=INT((A+B)-A) 150 BETA=CSNG(IBETA) 160 REM- BETA=CDBL(IBETA) 170 IT=0:B=ONE 180 IT=IT+1 190 B=B*BETA 200 IF (((B+ONE)-B)-ONE = ZERO) GOTO 180 210 IRND=0:BETAM1=BETA-ONE 220 IF ((A+BETAM1)-A <> ZERO) THEN IRND=1 230 NEGEP=IT+3:BETAIN=ONE/BETA:A=ONE 240 FOR I=1 TO NEGEP 250 A=A*BETAIN 260 NEXT I 270 B=A 280 IF ((ONE-A)-ONE <> ZERO) GOTO 310 290 A=A*BETA : NEGEP=NEGEP-1 300 GOTO 280 310 NEGEP=-NEGEP : EPSNEG=A 320 IF ((IBETA = 2) OR (IRND = 0)) GOTO 350 330 A=(A*(ONE+A))/(ONE+ONE) 340 IF ((ONE-A)-ONE <> ZERO) EPSNEG=A 350 MACHEP=-IT-3 : A=B 360 IF ((ONE+A)-ONE <> ZERO) GOTO 390 370 A=A*BETA : MACHEP=MACHEP+1 380 GOTO 360 390 EPS=A 400 IF ((IBETA=2) OR (IRND=0)) GOTO 430 410 A=(A*(ONE+A)) / (ONE+ONE) 420 IF ((ONE+A)-ONE <> ZERO) THEN EPS=A 430 NGRD=0 440 IF ((IRND=0) AND ((ONE+EPS)*ONE-ONE) <> ZERO) THEN NGRD=1 450 I=0:K=1:Z=BETAIN 460 Y=Z : Z=Y*Y : A=Z*ONE 470 IF ((A+A=ZERO) OR (ABS(Z) >= Y)) GOTO 500 480 I=I+1 : K=K+K 490 GOTO 460 500 IF (IBETA=10) GOTO 530 510 IEXP=I+1 : MX=K+K 520 GOTO 580 530 IEXP=2 : IZ=IBETA 540 IF (K=XMIN)) GOTO 630 610 K=K+1 620 GOTO 580 630 MINEXP=-K 640 IF ((MX>K+K-3) OR (IBETA=10)) GOTO 660 650 MX=MX+MX : IEXP=IEXP+1 660 MAXEXP=MX+MINEXP : I=MAXEXP+MINEXP 670 IF ((IBETA=2) AND (I=0)) THEN MAXEXP=MAXEXP-1 680 IF (I>20) THEN MAXEXP=MAXEXP-1 690 IF (A<>Y) THEN MAXEXP=MAXEXP-2 700 XMAX=ONE-EPSNEG 710 IF (XMAX*ONE <> XMAX) THEN XMAX=ONE-BETA*EPSNEG 720 XMAX=XMAX/(BETA*BETA*BETA*XMIN) : I=MAXEXP+MINEXP+3 740 IF (I<=0) GOTO 790 750 FOR J=1 TO I 760 IF (IBETA=2) THEN XMAX=XMAX+XMAX 770 IF (IBETA<>2) THEN XMAX=XMAX*BETA 780 NEXT J 790 PRINT IBETA,IT 810 PRINT IRND,NGRD 830 PRINT MACHEP,NEGEP 850 PRINT IEXP 870 PRINT MINEXP,MAXEXP 860 PRINT EPS, EPSNEG 880 PRINT XMIN,XMAX 890 END