Page images
PDF
EPUB

2590 GOSUB 8500 2600 LET B=-2 2610 LET A=B^B 2620 LET 0$="12"

2630 LET Y=.25 2640 GOSUB 8500 2650 LET C=-3 2660 LET A=B^C 2670 LET 0$="13" 2680 LET Y=-,125 2690 GOSUB 8500 2700 LET B=-3 2710 LET A=1^B

2720 LET O$="14"

2730 LET Y=1

2740 GOSUB 8500

2750 LET B=-2

2760 LET A=Bˆ0

2770 LET 0$="15"

2780 LET Y=1

2790 GOSUB 8500

2800 LET B=-3
2810 LET A=.5 B
2820 LET 0$="16"
2830 LET Y=8
2840 GOSUB 8500
2850 LET C=-.5
2860 LET A=.16^C
2870 LET 0$="17"

2880 LET Y=2.5
2890 GOSUB 8500

2900 LET A=.36^.5

2910 LET 0$="18"

2920 LET Y=.6

2930 GOSUB 8500 2940 LET B=-.5

2950 LET C=-3

2960 LET A=B^C

2970 LET 0$="19"

2980 LET Y=-8

2990 GOSUB 8500

3000 LET A=B^3 3010 LET 0$="20" 3020 LET Y=-,125

[blocks in formation]

7060 LET E1=0

7080 PRINT "CASE #","SHOULD BE","ACTUAL", "OUTCOME"

7090 PRINT

7300 RETURN

8000 REM SUBROUTINE TO END SECTION

8010 PRINT

8020 IF E1=0 THEN 8050

8025 PRINT "*** TEST FAILED IN ";E1;" CASE(S) ***"

[blocks in formation]

8500 REM HANDLE TEST CASE REPORT

8510 PRINT 0$,Y,A,

8520 LET P$="FAILS" 8530 LET M=0.1

8540 IF Y>1 THEN 8570

8550 IF Y<-1 THEN 8570

8560 LET M=0.01

8570 LET T=A-Y

8580 IF T>M THEN 8630

8590 LET T=Y-A

8600 IF T>M THEN 8630

8610 LET P$="PASSES"

8620 GOTO 8640

8630 LET E1=E1+1

8640 PRINT "TEST ";P$

8650 RETURN

8660 END

PROGRAM FILE 25: MULTIPLY, DIVIDE, AND INVOLUTE

ANSI STANDARD 7.2, 7.4

THIS PROGRAM TESTS THE GROSS SEMANTIC CHARACTERISTICS OF THE MULTIPLY, DIVIDE, AND INVOLUTION OPERATORS FOR THE CONSTRUCTION OF NUMERIC EXPRESSIONS.

EXPRESSIONS USING ONLY ONE OPERATOR AND CONSTANTS AND SIMPLE VARIABLES ARE EVALUATED, AND THE RESULTS TESTED AGAINST THE CORRECT VALUE. CONSTANTS ARE EXPRESSED IN NR1, NR2, AND NR3 FORM. THE VALUES OF THE OPERANDS AND RESULTS ARE RESTRICTED TO INTEGERS AND SIMPLE FRACTIONS TO AVOID ACCURACY PROBLEMS (ACCURACY IS ADDRESSED IN LATER TESTS).

SECTION 25.1: MULTIPLY

BEGIN TEST

[merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][ocr errors][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small][merged small]
[subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][ocr errors][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][subsumed][merged small][merged small][merged small][merged small][merged small]

10 PRINT "PROGRAM FILE 26: PRECEDENCE RULES FOR NUMERIC EXPRESSIONS." 20 PRINT 11 ANSI STANDARD 7.2, 7.4′′

30 PRINT

40 PRINT "THIS PROGRAM TESTS WHETHER THE PRECEDENCE RULES ARE" 50 PRINT "CORRECTLY IMPLEMENTED."

60 PRINT

70 PRINT "SECTION 26.1: PRECEDENCE ACCORDING TO OPERATOR AND" 80 PRINT "

90 PRINT

POSITION (LEFT TO RIGHT)."

100 PRINT "THIS SECTION TESTS THE PRECEDENCE RULES USING SIMPLE" 110 PRINT "INTEGER OPERANDS AND ALL ORDERED PAIRS OF OPERATORS" 120 PRINT "FOR WHICH THE ORDER OF EVALUATION MAKES A DIFFERENCE." 130 PRINT "NO PARENTHESES ARE USED."

[blocks in formation]

163 PRINT "CASE #","SHOULD BE","ACTUAL", "OUTCOME"

[blocks in formation]
[blocks in formation]

360 LET Y=-6

370 GOSUB 9000

380 LET 0$="6"

390 LET A=20.E-1-3 * 4

400 LET Y=-10

410 GOSUB 9000

420 LET A=8-4 / 2

430 LET 0$="7"

440 LET Y=6

450 GOSUB 9000

460 LET A=3-2 ^ 3

470 LET 0$="8"

480 LET Y=-5

490 GOSUB 9000

500 LET A=3 * 4+5

510 LET 0$="9"

520 LET Y=17

530 GOSUB 9000

540 LET 0$="10"

550 LET A=3.00E0 * 4.00E+00-5.00E-00

560 LET Y=7

570 GOSUB 9000

580 LET A=003.0*2. ^ 3.

590 LET O$="11"

600 LET Y=24

610 GOSUB 9000

620 LET A=6 / 2+1

630 LET 0$="12"

640 LET Y=4

650 GOSUB 9000

660 LET A=6 / 2-1

670 LET 0$="13"

680 LET Y=2

690 GOSUB 9000

700 LET A=2 / 1*2

710 LET O$="14"

720 LET Y=4

730 GOSUB 9000

740 LET A=8/2/2

750 LET O$="15"

760 LET Y=2

770 GOSUB 9000

780 LET 0$="16"

790 LET A=8/2^ 2

800 LET Y=2

810 GOSUB 9000

820 LET A=2^2+2

830 LET 0$="17"

840 LET Y=6

850 GOSUB 9000

860 LET A=2^3-2

« PreviousContinue »