Page images
PDF
EPUB

BEGIN TEST.

*** TEST PASSED ***

END TEST.

SECTION 27.5: COMPUTED ACCURACY OF NUMERIC VALUES.

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

[blocks in formation]

10 PRINT "PROGRAM FILE 28: EXCEPTION DIVISION BY ZERO." 20 PRINT " ANSI STANDARD 7.5"

30 PRINT

40 PRINT "THIS PROGRAM TESTS VARIOUS CASES OF DIVISION BY ZERO." 50 PRINT

60 PRINT "SECTION 28.1: POSITIVE NUMBER DIVIDED BY ZERO."

70 PRINT

80 PRINT "THIS SECTION TESTS THE RESULT OF DIVIDING A POSITIVE " 90 PRINT "QUANTITY BY ZERO."

100 PRINT

110 PRINT "TO PASS THIS TEST:"

120 PRINT

130 PRINT " 140 PRINT " 150 PRINT

160 PRINT " 170 PRINT "

180 PRINT 190 PRINT "

200 PRINT

210 LET B=6

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE" DISPLAYED, AND"

2) POSITIVE INFINITY MUST BE SUPPLIED AS THE VALUE" OF THE EXPRESSION AND EXECUTION CONTINUES."

220 LET A=5/(B-B)

BEGIN TEST."

230 PRINT "VALUE SUPPLIED = ";A

240 PRINT

250 IF A > .99E38 THEN 290

260 PRINT "*** TEST FAILED: VALUE SUPPLIED LESS THAN MINIMUM" 270 PRINT " POSITIVE MACHINE INFINITY. ***"

280 GOTO 320

=

290 PRINT "IF VALUE SUPPLIED POSITIVE MACHINE INFINITY, AND" 300 PRINT " EXCEPTION REPORTED, THEN"

[blocks in formation]

1060 PRINT "SECTION 28.2: NEGATIVE NUMBER DIVIDED BY ZERO." 1070 PRINT

1080 PRINT "THIS SECTION TESTS THE RESULT OF DIVIDING A NEGATIVE " 1090 PRINT "QUANTITY BY ZERO."

1100 PRINT

1110 PRINT "TO PASS THIS TEST:"

1120 PRINT

1130 PRINT " 1140 PRINT " 1150 PRINT 1160 PRINT " 1170 PRINT "

1180 PRINT

1190 PRINT "

1200 PRINT

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE"

DISPLAYED, AND"

2) NEGATIVE INFINITY MUST BE SUPPLIED AS THE VALUE" OF THE EXPRESSION AND EXECUTION CONTINUES."

BEGIN TEST."

1210 LET B=6

1220 LET A=-5/(B-B)

1230 PRINT "VALUE SUPPLIED = ";A

1240 PRINT

1250 IF A <-.99E38 THEN 1290

1260 PRINT "*** TEST FAILED: VALUE SUPPLIED GREATER THAN MINIMUM" 1270 PRINT "

1280 GOTO 1320

NEGATIVE MACHINE INFINITY. ****

1290 PRINT "IF VALUE SUPPLIED = NEGATIVE MACHINE INFINITY, AND" 1300 PRINT " EXCEPTION REPORTED, THEN"

1310 PRINT "*** TEST PASSED ****

[blocks in formation]

2060 PRINT "SECTION 28.3: ZERO DIVIDED BY ZERO."

2070 PRINT

2080 PRINT "THIS SECTION TESTS THE RESULT OF DIVIDING ZERO BY ZERO." 2100 PRINT

2110 PRINT "TO PASS THIS TEST:"

2120 PRINT

2130 PRINT " 2140 PRINT " 2150 PRINT 2160 PRINT " 2170 PRINT " 2180 PRINT 2190 PRINT " 2200 PRINT

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE"
DISPLAYED, AND"

2) POSITIVE INFINITY MUST BE SUPPLIED AS THE VALUE" OF THE EXPRESSION AND EXECUTION CONTINUES."

BEGIN TEST."

2210 LET B=6

2220 LET A=0/(B-B)

2230 PRINT "VALUE SUPPLIED = ";A

2240 PRINT

2250 IF A >.99E38 THEN 2290

2260 PRINT "*** TEST FAILED: VALUE SUPPLIED LESS THAN MINIMUM" 2270 PRINT POSITIVE MACHINE INFINITY. ***11

[ocr errors]

2280 GOTO 2320

2290 PRINT "IF VALUE SUPPLIED = POSITIVE MACHINE INFINITY, AND" 2300 PRINT EXCEPTION REPORTED, THEN"

[ocr errors]
[blocks in formation]

THIS PROGRAM TESTS VARIOUS CASES OF DIVISION BY ZERO.

SECTION 28.1: POSITIVE NUMBER DIVIDED BY ZERO.

THIS SECTION TESTS THE RESULT OF DIVIDING A POSITIVE
QUANTITY BY ZERO.

TO PASS THIS TEST:

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE
DISPLAYED, AND

2) POSITIVE INFINITY MUST BE SUPPLIED AS THE VALUE
OF THE EXPRESSION AND EXECUTION CONTINUES.

[blocks in formation]

THIS SECTION TESTS THE RESULT OF DIVIDING A NEGATIVE
QUANTITY BY ZERO.

TO PASS THIS TEST:

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE DISPLAYED, AND

2) NEGATIVE INFINITY MUST BE SUPPLIED AS THE VALUE OF THE EXPRESSION AND EXECUTION CONTINUES.

BEGIN TEST.

% DIVISION BY ZERO IN LINE 1220

VALUE SUPPLIED = -1.70141E+38

IF VALUE SUPPLIED = NEGATIVE MACHINE INFINITY, AND
EXCEPTION REPORTED, THEN

*** TEST PASSED ***

END TEST.

SECTION 28.3: ZERO DIVIDED BY ZERO.

THIS SECTION TESTS THE RESULT OF DIVIDING ZERO BY ZERO.

TO PASS THIS TEST:

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE
DISPLAYED, AND

2) POSITIVE INFINITY MUST BE SUPPLIED AS THE VALUE OF THE EXPRESSION AND EXECUTION CONTINUES.

BEGIN TEST.

% DIVISION BY ZERO IN LINE 2220

VALUE SUPPLIED = 1.70141E+38

IF VALUE SUPPLIED = POSITIVE MACHINE INFINITY, AND
EXCEPTION REPORTED, THEN

[blocks in formation]

40 PRINT "THIS PROGRAM TESTS VARIOUS CASES OF NUMERIC OVERFLOW." 50 PRINT

60 PRINT "SECTION 29.1: POSITIVE OVERFLOW"

70 PRINT

80 PRINT "THIS SECTION TESTS THE RESULT OF EXPRESSION EVALUATION"

90 PRINT "EXCEEDING POSITIVE MACHINE INFINITY."

100 PRINT

110 PRINT "TO PASS THIS TEST:"

120 PRINT

130 PRINT "

140 PRINT " 150 PRINT

160 PRINT " 170 PRINT "

180 PRINT

190 PRINT "

200 PRINT

210 LET M=10

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE"
DISPLAYED, AND"

2) POSITIVE INFINITY MUST BE SUPPLIED AS THE VALUE" OF THE EXPRESSION AND EXECUTION CONTINUES."

BEGIN TEST"

220 LET F=1

230 LET A=1E36

240 LET B=1

250 PRINT "ABOUT TO COMPUTE ";A;" * ";M

260 LET A=A*M

270 PRINT "RESULT = ";A

280 PRINT

290 PRINT ".

300 PRINT

310 IF B>=A THEN 360

320 LET B=A

330 LET F=F*1.1

340 LET M=10°F

350 GOTO 250

360 REM CONVERGE

370 IF A>.99E38 THEN 410

380 PRINT "*** TEST FAILED: VALUE SUPPLIED LESS THAN MINIMUM"
390 PRINT "
POSITIVE MACHINE INFINITY. ***11

400 GOTO 440

410 PRINT "LAST TWO MULTIPLICATIONS SHOULD HAVE BEEN REPORTED" 420 PRINT "AS OVERFLOW, AND POSITIVE INFINITY SUPPLIED; IF SO," 430 PRINT "*** TEST PASSED *** OTHERWISE *** TEST FAILED ***" 440 PRINT

[blocks in formation]

490 PRINT "THIS SECTION TESTS THE RESULT OF EXPRESSION EVALUATION" 500 PRINT "EXCEEDING NEGATIVE MACHINE INFINITY."

510 PRINT

520 PRINT "TO PASS THIS TEST:"

530 PRINT

540 PRINT " 550 PRINT " 560 PRINT 570 PRINT " 580 PRINT " 590 PRINT

1) A MESSAGE IDENTIFYING THE EXCEPTION MUST BE" DISPLAYED, AND"

2) NEGATIVE INFINITY MUST BE SUPPLIED AS THE VALUE" OF THE EXPRESSION AND EXECUTION CONTINUES."

« PreviousContinue »