1-- C45531G.ADA
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 THAT THE OPERATOR "*" PRODUCES CORRECT RESULTS
27--     FOR MIXED FIXED POINT AND INTEGER TYPES USING 4 SUBTESTS.
28--       THIS TEST REQUIRES MIN_WORD_LENGTH = 16.
29--       THIS TEST USES VALUES OF DELTA WHICH ARE GREATER THAN OR
30--       EQUAL TO 0.5.
31--
32--     TEST CASES ARE:
33--       A) INTEGER * FIXED WHEN ALL VALUES ARE MODEL NUMBERS.
34--       B) FIXED * INTEGER WHEN ALL VALUES ARE MODEL NUMBERS.
35--       C) INTEGER * FIXED FOR NON-MODEL NUMBERS.
36--       D) FIXED * INTEGER FOR NON-MODEL NUMBERS.
37--
38--     REPEAT FOR MINIMUM REQUIRED WORD LENGTHS OF 12, 16, 32 AND 48,
39--     WITH RANGE <, =, AND > THAN 1.0 AND
40--     WITH DELTA <, =, AND > THAN 1.0.
41
42-- HISTORY:
43--     NTW 09/08/86 CREATED ORIGINAL TEST.
44--     RJW 11/05/86 REVISED COMMENTS.
45--     DHH 01/13/88 ADDED APPLICABILITY CRITERIA AND STANDARD HEADER.
46--     BCB 04/27/90 REVISED APPLICABILITY CRITERIA.
47--     BCB 10/03/90 REMOVED APPLICABILITY CRITERIA AND N/A => ERROR
48--                  LINE.  CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
49
50WITH REPORT;
51PROCEDURE C45531G IS
52
53     USE REPORT;
54
55     MIN_WORD_LENGTH : CONSTANT := 16;
56     FULL_SCALE      : CONSTANT := 2 ** (MIN_WORD_LENGTH - 1);
57     FORTH           : CONSTANT := FULL_SCALE / 4;
58     RNG1            : CONSTANT := FULL_SCALE * 0.5;
59     TYPE FX_0P5  IS DELTA 0.5 RANGE -RNG1 * 1 .. RNG1 * 1 - 0.5;
60     TYPE FX_1    IS DELTA 1.0 RANGE -RNG1 * 2 .. RNG1 * 2 - 1.0;
61     TYPE FX_RNG1 IS DELTA RNG1
62                    RANGE -RNG1 * FULL_SCALE .. RNG1 * (FULL_SCALE - 1);
63
64BEGIN TEST ("C45531G", "MIXED FIXED POINT AND INTEGER ""*"" "
65                    &  "FOR DELTA <, =, > 1.0");
66
67     --------------------------------------------------
68
69     -- CASE A) INTEGER * FIXED WHEN ALL VALUES ARE MODEL NUMBERS.
70
71A:   DECLARE
72          A              : INTEGER := 0;
73          B              : FX_0P5  := 0.0;
74          RESULT_VALUE   : FX_0P5  := 0.0;
75          LOWEST_ACCEPTABLE_VALUE  : FX_0P5 := FX_0P5 (7.5);
76          HIGHEST_ACCEPTABLE_VALUE : FX_0P5 := FX_0P5 (7.5);
77     BEGIN
78          IF EQUAL (3, 3) THEN
79               A := 3;
80               B := FX_0P5 (2.5);               -- A MODEL NUMBER
81          END IF;
82
83          RESULT_VALUE := A * B;
84
85          IF    (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
86             OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
87               FAILED ("RESULT OF ""*"" OUTSIDE RESULT MODEL INTERVAL "
88                    &  "FOR INTEGER * FIXED "
89                    &  "WHEN ALL VALUES ARE MODEL NUMBERS");
90          END IF;
91     END A;
92
93     --------------------------------------------------
94
95     -- CASE B) FIXED * INTEGER WHEN ALL VALUES ARE MODEL NUMBERS.
96
97B:   DECLARE
98          A              : FX_1    := 0.0;
99          B              : INTEGER := 0;
100          RESULT_VALUE   : FX_1    := 0.0;
101          LOWEST_ACCEPTABLE_VALUE  : FX_1 := FX_1 (3 * FORTH);
102          HIGHEST_ACCEPTABLE_VALUE : FX_1 := FX_1 (3 * FORTH);
103     BEGIN
104          IF EQUAL (3, 3) THEN
105               A := FX_1 (FULL_SCALE / 8);        -- A MODEL NUMBER
106               B := 6;
107          END IF;
108
109          RESULT_VALUE := A * B;
110
111          IF    (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
112             OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
113               FAILED ("RESULT OF ""*"" OUTSIDE RESULT MODEL INTERVAL "
114                    &  "FOR FIXED * INTEGER "
115                    &  "WHEN ALL VALUES ARE MODEL NUMBERS");
116          END IF;
117     END B;
118
119     --------------------------------------------------
120
121     -- CASE C) INTEGER * FIXED FOR NON-MODEL NUMBERS.
122
123C:   DECLARE
124          A              : INTEGER := 0;
125          B              : FX_RNG1 := 0.0;
126          RESULT_VALUE   : FX_RNG1 := 0.0;
127          LOW_COUNT     : CONSTANT := (3 * (FORTH + 0) );
128          HIGH_COUNT    : CONSTANT := (3 * (FORTH + 1) );
129          LOWEST_ACCEPTABLE_VALUE  :  FX_RNG1
130                                   := FX_RNG1 (RNG1 * LOW_COUNT );
131          HIGHEST_ACCEPTABLE_VALUE :  FX_RNG1
132                                   := FX_RNG1 (RNG1 * HIGH_COUNT);
133     BEGIN
134          IF EQUAL (3, 3) THEN        -- B NOT A MODEL NUMBER
135               A := 3;
136               B := FX_RNG1 (RNG1 * FORTH + 0.5);
137          END IF;
138
139          RESULT_VALUE := A * B;
140
141          IF    (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
142             OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
143               FAILED ("RESULT OF ""*"" OUTSIDE RESULT MODEL INTERVAL "
144                    &  "FOR INTEGER * FIXED FOR NON-MODEL NUMBERS");
145
146          END IF;
147     END C;
148
149     --------------------------------------------------
150
151     -- CASE D) FIXED * INTEGER FOR NON-MODEL NUMBERS.
152
153D:   DECLARE
154          A              : FX_RNG1 := 0.0;
155          B              : INTEGER := 0;
156          RESULT_VALUE   : FX_RNG1 := 0.0;
157          LOW_COUNT     : CONSTANT := (3 * (FORTH + 0) );
158          HIGH_COUNT    : CONSTANT := (3 * (FORTH + 1) );
159          LOWEST_ACCEPTABLE_VALUE  :  FX_RNG1
160                                   := FX_RNG1 (RNG1 * LOW_COUNT );
161          HIGHEST_ACCEPTABLE_VALUE :  FX_RNG1
162                                   := FX_RNG1 (RNG1 * HIGH_COUNT);
163     BEGIN
164          IF EQUAL (3, 3) THEN        -- A NOT A MODEL NUMBER
165               A := FX_RNG1 (RNG1 * FORTH + 0.5);
166               B := 3;
167          END IF;
168
169          RESULT_VALUE := A * B;
170
171          IF    (RESULT_VALUE < LOWEST_ACCEPTABLE_VALUE)
172             OR (RESULT_VALUE > HIGHEST_ACCEPTABLE_VALUE) THEN
173               FAILED ("RESULT OF ""*"" OUTSIDE RESULT MODEL INTERVAL "
174                    &  "FOR FIXED * INTEGER FOR NON-MODEL NUMBERS");
175          END IF;
176     END D;
177
178     --------------------------------------------------
179
180
181     RESULT;
182
183END C45531G;
184