Page images
PDF
EPUB

3510 PRINT "-9.999988899E36";

3520 GOTO 3600

3600 LET U$="T"

3610 LET E$="T"

3620 IF -9.999988888E36 > B THEN 3640 3630 LET U$="F"

3640 IF -9.999988888E36 B THEN 3660

3650 LET E$="F"

3660 REM COMPARISONS FINISHED

3670 GOSUB 8160

3680 NEXT I

3690 GOSUB 8280

5000 PRINT "SECTION 27.3: ACCURACY IN THE COMPARISON OF CONSTANTS." 5010 PRINT

5020 PRINT "THIS SECTION COMPARES TWO CONSTANTS WHICH HAVE"

5030 PRINT "NUMERICALLY 'CLOSE' VALUES AND THEN DETERMINES WHETHER THE" 5040 PRINT "IMPLEMENTATION CAN DISTINGUISH BETWEEN THEM OR IF THEY ARE" 5050 PRINT "TREATED AS EQUAL."

5060 PRINT

5070 LET C$="< ="

5080 GOSUB 8000

5090 LET A$="9.40395E-37 : "

5100 FOR I=6 TO 9

5110 PRINT A$;

5120 LET U$="T"

5130 LET E$="T"

5140 LET J=I-5

5150 ON J GOTO 5200,5300,5400, 5500

5200 IF 9.40395E-37 < 9.40396E-37 THEN 5220

5210 LET U$="F"

5220 IF 9.40395E-37 = 9.40396E-37 THEN 5240 5230 LET E$="F"

5240 PRINT "9.40396E-37";

5250 GOTO 5600

5300 IF 9.40395E-37 < 9.403951E-37 THEN 5320 5310 LET U$="F"

5320 IF 9.40395E-37 = 9.403951E-37 THEN 5340 5330 LET E$="F"

5340 PRINT "9.403951E-37";

5350 GOTO 5600

5400 IF 9.40395E-37 < 9.4039501E-37 THEN 5420 5410 LET U$="F"

5420 IF 9.40395E-37 = 9.4039501E-37 THEN 5440 5430 LET E$="F"

5440 PRINT "9.4039501E-37";

5450 GOTO 5600

5500 IF 9.40395E-37 < 9.40395001E-37 THEN 5520 5510 LET U$="F"

5520 IF 9.40395E-37 = 9.40395001E-37 THEN 5540 5530 LET E$="F"

5540 PRINT "9.40395001E-37";

5550 GOTO 5600

5600 REM COMPARISONS FINISHED

5610 GOSUB 8160

5620 NEXT I

5630 GOSUB 8280

5800 PRINT "SECTION 27.4: ACCURACY FOR CONSTANTS EXPRESSED WITH"
5810 PRINT "
DIFFERENT EXPONENTS."

5820 PRINT

5830 PRINT "CONSTANTS MUST BE ACCURATE EVEN WHEN NOT EXPRESSED IN" 5840 PRINT "NORMALIZED FORM (1 <= SIGNIFICAND < 10)."

[blocks in formation]

5880 IF .0000000999991E-18 >= 99999200000E-36 THEN 5950 5890 IF -.0000000999991E-18 <= -99999200000E-36 THEN 5950 5900 IF .0000000999992E-18 >= 99999300000E-36 THEN 5950 5910 IF -.0000000999992E-18 <= -99999300000E-36 THEN 5950 5920 IF .0000000999993E-18 >= 99999400000E-36 THEN 5950

5930 IF .0000000999993E-18 <=-99999400000E-36 THEN 5950 5940 PRINT "*** TEST PASSED ***"

[blocks in formation]

6000 PRINT "SECTION 27.5: COMPUTED ACCURACY OF NUMERIC VALUES." 6010 PRINT

6020 PRINT "THIS SECTION USES A COMPUTATIONAL ALGORITHM TO ATTEMPT TO" 6030 PRINT "DISCOVER THIS IMPLEMENTATION'S INTERNAL ACCURACY. BECAUSE" 6040 PRINT "THE ALGORITHM RELIES SOMEWHAT ON ACCURACY OF EXPRESSION" 6050 PRINT "EVALUATION, THE RESULTS ARE NOT ABSOLUTELY TRUSTWORTHY AND" 6060 PRINT "SHOULD BE INTERPRETED IN LIGHT OF GENERAL KNOWLEDGE OF" 6070 PRINT "THE CHARACTERISTICS OF THE SYSTEM."

6080 PRINT

6090 PRINT "*** THIS TEST IS INFORMATIVE ONLY ***"

[blocks in formation]

6290 REM THE NEXT FOUR STATEMENTS HAVE NO ALGORITHMIC PURPOSE
6300 REM THEY ARE AN ATTEMPT TO FORCE THE VARIABLE T1 TO BE STORED
6310 REM RATHER THAN SAVED IN OVERLENGTH REGISTERS, AS IS DONE
6320 REM BY SOME MACHINES, WITH AN OPTIMIZING COMPILER.
6325 LET V=1

6330 LET U=E+D
6340 LET V=U*D*(-V)

6350 IF V < 0 THEN 6330

6360 LET D=D+1

6370 IF D>500 THEN 64 10

6380 IF T1 <S THEN 6260

6390 PRINT "COMPUTED ACCURACY = ";D; B$;" DIGITS."

6400 RETURN

6410 PRINT "UNABLE TO COMPUTE ACCURACY OF ";B$;" DIGITS." 6420 RETURN

[blocks in formation]

8030 PRINT "NUMERIC VALUES"; TAB(T1); "DIGITS OF"; TAB(T2); 8040 PRINT "RESULT OF"

8050 PRINT "BEING COMPARED"; TAB(T1); "DECIMAL"; TAB(T2); 8060 PRINT "COMPARISONS"

8070 PRINT TAB(T1); "ACCURACY"; TAB (T2); C$

8080 PRINT

8090 REM NO. OF ANOMALOUS RESULTS (BOTH TRUE OR BOTH FALSE) 8100 LET S2=0

[blocks in formation]

8330 PRINT "*** TEST INDICATES DECIMAL ACCURACY OF AT ";T$;" ";S0; 8340 PRINT "DIGITS. ****

8350 IF SO < 6 THEN 8400

8360 PRINT "IF DOCUMENTATION FOR THE IMPLEMENTATION-DEFINED ACCURACY" 8370 PRINT " FOR NUMERIC VALUES IS COMPATIBLE WITH THIS RESULT, THEN" 8380 PRINT "*** TEST PASSED ***"1

8390 GOTO 8410

8400 PRINT "*** TEST FAILED: MINIMUM ACCURACY IS SIX DIGITS. ***" 8410 PRINT

8420 IF S2=0 THEN 8460

8430 PRINT "*** NOTE ANOMALOUS COMPARISON RESULTS IN THE ";S2;" ROW(S)"

8440 PRINT "

8450 PRINT

8460 PRINT "

8470 PRINT

8480 RETURN

8490 END

ABOVE FOLLOWED BY ASTERISKS. ***11

END TEST."

PROGRAM FILE 27: ACCURACY OF CONSTANTS AND VARIABLES.
ANSI STANDARD 5.2, 5.4, 6.2, 6.4, 10.4

*** NOTE: THIS PROGRAM MAKES USE OF THE ON-GOTO STATEMENT
AND FOR-BLOCKS (THE FOR AND NEXT STATEMENTS) WHICH
HAVE NOT YET BEEN TESTED. IF SUBSEQUENT TESTS SHOW
THESE FEATURES TO BE INCORRECTLY IMPLEMENTED, THEN THE
VALIDITY OF THE RESULTS OF THIS TEST ROUTINE IS DOUBTFUL.

THIS PROGRAM TESTS THE LEVEL OF ACCURACY OF NUMERIC VALUES,
USING THE IF-THEN STATEMENT.

SECTION 27.1: ACCURACY IN COMPARISON OF VARIABLES.

THIS SECTION COMPARES TWO VARIABLES WHICH HAVE BEEN ASSIGNED
NUMERICALLY 'CLOSE' VALUES AND THEN DETERMINES WHETHER THE
IMPLEMENTATION CAN DISTINGUISH BETWEEN THEM OR IF THEY ARE
TREATED AS EQUAL.

[blocks in formation]

*** TEST INDICATES DECIMAL ACCURACY OF AT MOST 8 DIGITS. ***
IF DOCUMENTATION FOR THE IMPLEMENTATION-DEFINED ACCURACY
FOR NUMERIC VALUES IS COMPATIBLE WITH THIS RESULT, THEN
*** TEST PASSED ***

END TEST.

SECTION 27.2: ACCURACY IN THE COMPARISON OF VARIABLES

WITH CONSTANTS.

THIS SECTION COMPARES A VARIABLE AND A CONSTANT WHICH HAVE NUMERICALLY 'CLOSE' VALUES AND THEN DETERMINES WHETHER THE IMPLEMENTATION CAN DISTINGUISH BETWEEN THEM OR IF THEY ARE TREATED AS EQUAL.

[blocks in formation]

*** TEST INDICATES DECIMAL ACCURACY OF AT MOST 8 DIGITS. *** IF DOCUMENTATION FOR THE IMPLEMENTATION-DEFINED ACCURACY FOR NUMERIC VALUES IS COMPATIBLE WITH THIS RESULT, THEN *** TEST PASSED ***

END TEST.

SECTION 27.3: ACCURACY IN THE COMPARISON OF CONSTANTS.

THIS SECTION COMPARES TWO CONSTANTS WHICH HAVE
NUMERICALLY 'CLOSE' VALUES AND THEN DETERMINES WHETHER THE
IMPLEMENTATION CAN DISTINGUISH BETWEEN THEM OR IF THEY ARE
TREATED AS EQUAL.

[blocks in formation]

*** TEST INDICATES DECIMAL ACCURACY OF AT MOST 7 DIGITS. *** IF DOCUMENTATION FOR THE IMPLEMENTATION-DEFINED ACCURACY FOR NUMERIC VALUES IS COMPATIBLE WITH THIS RESULT, THEN *** TEST PASSED ***

END TEST.

SECTION 27.4: ACCURACY FOR CONSTANTS EXPRESSED WITH
DIFFERENT EXPONENTS.

CONSTANTS MUST BE ACCURATE EVEN WHEN NOT EXPRESSED IN
NORMALIZED FORM (1 <= SIGNIFICAND <10).

« PreviousContinue »