1-- C45536A.DEP
2
3--                             Grant of Unlimited Rights
4--
5--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7--     unlimited rights in the software and documentation contained herein.
8--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9--     this public release, the Government intends to confer upon all
10--     recipients unlimited rights  equal to those held by the Government.
11--     These rights include rights to use, duplicate, release or disclose the
12--     released technical data and computer software in whole or in part, in
13--     any manner and for any purpose whatsoever, and to have or permit others
14--     to do so.
15--
16--                                    DISCLAIMER
17--
18--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23--     PARTICULAR PURPOSE OF SAID MATERIAL.
24--*
25-- OBJECTIVE:
26--     CHECK FIXED POINT MULTIPLICATION AND DIVISION WHEN 'SMALL OF
27--     THE OPERANDS ARE NOT BOTH POWERS OF THE SAME BASE VALUE.
28
29-- APPLICABILITY CRITERIA:
30--     THIS TEST IS APPLICABLE TO IMPLEMENTATIONS WHICH SUPPORT
31--     REPRESENTATION CLAUSES FOR 'SMALL WHICH ARE NOT POWERS OF TWO.
32
33--     IF SUCH REPRESENTATION CLAUSES ARE NOT SUPPORTED, THEN THE
34--     REPRESENTATION CLAUSE FOR CHECK_TYPE MUST BE REJECTED.
35
36-- HISTORY:
37--     BCB 02/02/88  CREATED ORIGINAL TEST.
38
39WITH REPORT; USE REPORT;
40
41PROCEDURE C45536A IS
42
43     TYPE CHECK_TYPE IS DELTA 2.0**(-1) RANGE 0.0 .. 8.0;
44     FOR CHECK_TYPE'SMALL USE 0.2;                     -- N/A => ERROR.
45
46     TYPE F1 IS DELTA 2.0**(-1) RANGE 0.0 .. 8.0;
47     FOR F1'SMALL USE 0.5;
48
49     TYPE F2 IS DELTA 2.0**(-1) RANGE 0.0 .. 8.0;
50     FOR F2'SMALL USE 0.2;
51
52     TYPE F3 IS DELTA 2.0**(-1) RANGE 0.0 .. 8.0;
53     FOR F3'SMALL USE 0.1;
54
55     A : F1;
56     B : F2;
57     C : F3;
58
59     FUNCTION IDENT_FIX(X : F3) RETURN F3 IS
60     BEGIN
61          IF EQUAL(3,3) THEN
62               RETURN X;
63          ELSE
64               RETURN 0.0;
65          END IF;
66     END IDENT_FIX;
67
68BEGIN
69     TEST ("C45536A", "CHECK FIXED POINT MULTIPLICATION AND DIVISION " &
70                      "WHEN 'SMALL OF THE OPERANDS ARE NOT BOTH " &
71                      "POWERS OF THE SAME BASE VALUE");
72
73     A := 1.0; B := 1.0; C := F3(A * B);
74
75     IF C /= IDENT_FIX(1.0) THEN
76          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 1");
77     END IF;
78
79     C := F3(A / B);
80
81     IF C /= IDENT_FIX(1.0) THEN
82          FAILED ("IMPROPER RESULTS FOR DIVISION - 1");
83     END IF;
84
85     A := 1.0; B := 0.3; C := F3(A * B);
86
87     IF C NOT IN IDENT_FIX(0.2) .. IDENT_FIX(0.4) THEN
88          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 2");
89     END IF;
90
91     B := 0.25; C := F3(A / B);
92
93     IF C NOT IN IDENT_FIX(2.5) .. IDENT_FIX(5.0) THEN
94          FAILED ("IMPROPER RESULTS FOR DIVISION - 2");
95     END IF;
96
97     A := 0.5; B := 0.3; C := F3(A * B);
98
99     IF C NOT IN IDENT_FIX(0.1) .. IDENT_FIX(0.2) THEN
100          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 3");
101     END IF;
102
103     C := F3(A / B);
104
105     IF C NOT IN IDENT_FIX(1.2) .. IDENT_FIX(2.5) THEN
106          FAILED ("IMPROPER RESULTS FOR DIVISION - 3");
107     END IF;
108
109     B := 0.3; C := 0.2; A := F1(B * C);
110
111     IF A NOT IN F1(IDENT_FIX(0.0)) .. F1(IDENT_FIX(0.5)) THEN
112          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 4");
113     END IF;
114
115     A := 1.0; B := 1.6; C := F3(A / B);
116
117     IF C NOT IN IDENT_FIX(0.6) .. IDENT_FIX(0.7) THEN
118          FAILED ("IMPROPER RESULTS FOR DIVISION - 4");
119     END IF;
120
121     A := 0.75; B := 0.4; C := F3(A * B);
122
123     IF C NOT IN IDENT_FIX(0.2) .. IDENT_FIX(0.4) THEN
124          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 5");
125     END IF;
126
127     A := 0.8; C := F3(A / B);
128
129     IF C NOT IN IDENT_FIX(1.2) .. IDENT_FIX(2.5) THEN
130          FAILED ("IMPROPER RESULTS FOR DIVISION - 5");
131     END IF;
132
133     A := 0.8; B := 0.4; C := F3(A * B);
134
135     IF C NOT IN IDENT_FIX(0.2) .. IDENT_FIX(0.4) THEN
136          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 6");
137     END IF;
138
139     A := 0.75; C := F3(A / B);
140
141     IF C NOT IN IDENT_FIX(1.2) .. IDENT_FIX(2.5) THEN
142          FAILED ("IMPROPER RESULTS FOR DIVISION - 6");
143     END IF;
144
145     A := 0.7; B := 0.3; C := F3(A * B);
146
147     IF C NOT IN IDENT_FIX(0.1) .. IDENT_FIX(0.4) THEN
148          FAILED ("IMPROPER RESULTS FOR MULTIPLICATION - 7");
149     END IF;
150
151     C := F3(A / B);
152
153     IF C NOT IN IDENT_FIX(1.2) .. IDENT_FIX(5.0) THEN
154          FAILED ("IMPROPER RESULTS FOR DIVISION - 7");
155     END IF;
156
157     RESULT;
158END C45536A;
159