3 -- Grant of Unlimited Rights
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
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.
27 -- Check that the multiplying operators for a decimal fixed point type
28 -- return values that are integral multiples of the small of the type.
29 -- Check the case where the operand and result types are the same.
31 -- Check that if the mathematical result is between multiples of the
32 -- small of the result type, the result is truncated toward zero.
35 -- The test verifies that decimal multiplication and division behave as
36 -- expected for types with various digits, delta, and Machine_Radix
39 -- The iteration, operation, and operand counts in the foundation, and
40 -- the operations and operand tables in the test, are given values such
41 -- that, when the operations loop is complete, truncation of inexact
42 -- results should cause the result returned by the operations loop to be
43 -- the same as that used to initialize the loop's cumulator variable (in
47 -- This test consists of the following files:
52 -- APPLICABILITY CRITERIA:
53 -- This test is only applicable for a compiler attempting validation
54 -- for the Information Systems Annex.
58 -- 13 Mar 96 SAIC Prerelease version for ACVC 2.1.
59 -- 04 Aug 96 SAIC Updated prologue.
65 ---=---=---=---=---=---=---=---=---=---=---
67 type Micro
is delta 10.0**(-5) digits 6; -- range -9.99999 ..
68 for Micro
'Machine_Radix use 2; -- +9.99999
70 function Multiply
(Left
, Right
: Micro
) return Micro
;
71 function Divide
(Left
, Right
: Micro
) return Micro
;
74 type Micro_Optr_Ptr
is access function (Left
, Right
: Micro
) return Micro
;
76 Micro_Mult
: Micro_Optr_Ptr
:= Multiply
'Access;
77 Micro_Div
: Micro_Optr_Ptr
:= Divide
'Access;
79 ---=---=---=---=---=---=---=---=---=---=---
81 type Basic
is delta 0.01 digits 11; -- range -999,999,999.99 ..
82 for Basic
'Machine_Radix use 10; -- +999,999,999.99
84 function Multiply
(Left
, Right
: Basic
) return Basic
;
85 function Divide
(Left
, Right
: Basic
) return Basic
;
88 type Basic_Optr_Ptr
is access function (Left
, Right
: Basic
) return Basic
;
90 Basic_Mult
: Basic_Optr_Ptr
:= Multiply
'Access;
91 Basic_Div
: Basic_Optr_Ptr
:= Divide
'Access;
93 ---=---=---=---=---=---=---=---=---=---=---
95 type Broad
is delta 10.0**(-3) digits 10; -- range -9,999,999.999 ..
96 for Broad
'Machine_Radix use 2; -- +9,999,999.999
98 function Multiply
(Left
, Right
: Broad
) return Broad
;
99 function Divide
(Left
, Right
: Broad
) return Broad
;
102 type Broad_Optr_Ptr
is access function (Left
, Right
: Broad
) return Broad
;
104 Broad_Mult
: Broad_Optr_Ptr
:= Multiply
'Access;
105 Broad_Div
: Broad_Optr_Ptr
:= Divide
'Access;
107 ---=---=---=---=---=---=---=---=---=---=---
112 --==================================================================--
115 package body CXF2A02_0
is
117 ---=---=---=---=---=---=---=---=---=---=---
119 function Multiply
(Left
, Right
: Micro
) return Micro
is
121 return (Left
* Right
); -- Decimal fixed multiplication.
124 function Divide
(Left
, Right
: Micro
) return Micro
is
126 return (Left
/ Right
); -- Decimal fixed division.
129 ---=---=---=---=---=---=---=---=---=---=---
131 function Multiply
(Left
, Right
: Basic
) return Basic
is
133 return (Left
* Right
); -- Decimal fixed multiplication.
136 function Divide
(Left
, Right
: Basic
) return Basic
is
138 return (Left
/ Right
); -- Decimal fixed division.
141 ---=---=---=---=---=---=---=---=---=---=---
143 function Multiply
(Left
, Right
: Broad
) return Broad
is
145 return (Left
* Right
); -- Decimal fixed multiplication.
148 function Divide
(Left
, Right
: Broad
) return Broad
is
150 return (Left
/ Right
); -- Decimal fixed division.
153 ---=---=---=---=---=---=---=---=---=---=---
158 --==================================================================--
162 package CXF2A02_0
.CXF2A02_1
is
164 ---=---=---=---=---=---=---=---=---=---=---
166 type Micro_Ops
is array (FXF2A00
.Optr_Range
) of Micro_Optr_Ptr
;
167 type Micro_Opnds
is array (FXF2A00
.Opnd_Range
) of Micro
;
169 Micro_Mult_Operator_Table
: Micro_Ops
:= ( Micro_Mult
, Micro_Mult
,
170 Micro_Mult
, Micro_Mult
,
171 Micro_Mult
, Micro_Mult
);
173 Micro_Div_Operator_Table
: Micro_Ops
:= ( Micro_Div
, Micro_Div
,
174 Micro_Div
, Micro_Div
,
175 Micro_Div
, Micro_Div
);
177 Micro_Mult_Operand_Table
: Micro_Opnds
:= ( 2.35119,
183 Micro_Div_Operand_Table
: Micro_Opnds
:= ( 0.58739,
189 function Test_Micro_Ops
is new FXF2A00
.Operations_Loop
190 (Decimal_Fixed
=> Micro
,
191 Operator_Ptr
=> Micro_Optr_Ptr
,
192 Operator_Table
=> Micro_Ops
,
193 Operand_Table
=> Micro_Opnds
);
195 ---=---=---=---=---=---=---=---=---=---=---
197 type Basic_Ops
is array (FXF2A00
.Optr_Range
) of Basic_Optr_Ptr
;
198 type Basic_Opnds
is array (FXF2A00
.Opnd_Range
) of Basic
;
200 Basic_Mult_Operator_Table
: Basic_Ops
:= ( Basic_Mult
, Basic_Mult
,
201 Basic_Mult
, Basic_Mult
,
202 Basic_Mult
, Basic_Mult
);
204 Basic_Div_Operator_Table
: Basic_Ops
:= ( Basic_Div
, Basic_Div
,
205 Basic_Div
, Basic_Div
,
206 Basic_Div
, Basic_Div
);
208 Basic_Mult_Operand_Table
: Basic_Opnds
:= ( 127.10,
214 Basic_Div_Operand_Table
: Basic_Opnds
:= ( 0.03,
220 function Test_Basic_Ops
is new FXF2A00
.Operations_Loop
221 (Decimal_Fixed
=> Basic
,
222 Operator_Ptr
=> Basic_Optr_Ptr
,
223 Operator_Table
=> Basic_Ops
,
224 Operand_Table
=> Basic_Opnds
);
226 ---=---=---=---=---=---=---=---=---=---=---
228 type Broad_Ops
is array (FXF2A00
.Optr_Range
) of Broad_Optr_Ptr
;
229 type Broad_Opnds
is array (FXF2A00
.Opnd_Range
) of Broad
;
231 Broad_Mult_Operator_Table
: Broad_Ops
:= ( Broad_Mult
, Broad_Mult
,
232 Broad_Mult
, Broad_Mult
,
233 Broad_Mult
, Broad_Mult
);
235 Broad_Div_Operator_Table
: Broad_Ops
:= ( Broad_Div
, Broad_Div
,
236 Broad_Div
, Broad_Div
,
237 Broad_Div
, Broad_Div
);
239 Broad_Mult_Operand_Table
: Broad_Opnds
:= ( 589.720,
245 Broad_Div_Operand_Table
: Broad_Opnds
:= ( 0.008,
251 function Test_Broad_Ops
is new FXF2A00
.Operations_Loop
252 (Decimal_Fixed
=> Broad
,
253 Operator_Ptr
=> Broad_Optr_Ptr
,
254 Operator_Table
=> Broad_Ops
,
255 Operand_Table
=> Broad_Opnds
);
257 ---=---=---=---=---=---=---=---=---=---=---
259 end CXF2A02_0
.CXF2A02_1
;
262 --==================================================================--
265 with CXF2A02_0
.CXF2A02_1
;
269 package Data
renames CXF2A02_0
.CXF2A02_1
;
271 use type CXF2A02_0
.Micro
;
272 use type CXF2A02_0
.Basic
;
273 use type CXF2A02_0
.Broad
;
275 Micro_Expected
: constant CXF2A02_0
.Micro
:= 1.0;
276 Basic_Expected
: constant CXF2A02_0
.Basic
:= 1.0;
277 Broad_Expected
: constant CXF2A02_0
.Broad
:= 1.0;
279 Micro_Actual
: CXF2A02_0
.Micro
;
280 Basic_Actual
: CXF2A02_0
.Basic
;
281 Broad_Actual
: CXF2A02_0
.Broad
;
284 Report
.Test
("CXF2A02", "Check decimal multiplication and division, " &
285 "where the operand and result types are the same");
287 ---=---=---=---=---=---=---=---=---=---=---
290 Micro_Actual
:= Data
.Test_Micro_Ops
(1.0,
291 Data
.Micro_Mult_Operator_Table
,
292 Data
.Micro_Mult_Operand_Table
);
294 if Micro_Actual
/= Micro_Expected
then
295 Report
.Failed
("Wrong result for type Micro multiplication");
300 Micro_Actual
:= Data
.Test_Micro_Ops
(1.0,
301 Data
.Micro_Div_Operator_Table
,
302 Data
.Micro_Div_Operand_Table
);
304 if Micro_Actual
/= Micro_Expected
then
305 Report
.Failed
("Wrong result for type Micro division");
308 ---=---=---=---=---=---=---=---=---=---=---
311 Basic_Actual
:= Data
.Test_Basic_Ops
(1.0,
312 Data
.Basic_Mult_Operator_Table
,
313 Data
.Basic_Mult_Operand_Table
);
315 if Basic_Actual
/= Basic_Expected
then
316 Report
.Failed
("Wrong result for type Basic multiplication");
321 Basic_Actual
:= Data
.Test_Basic_Ops
(1.0,
322 Data
.Basic_Div_Operator_Table
,
323 Data
.Basic_Div_Operand_Table
);
325 if Basic_Actual
/= Basic_Expected
then
326 Report
.Failed
("Wrong result for type Basic division");
329 ---=---=---=---=---=---=---=---=---=---=---
332 Broad_Actual
:= Data
.Test_Broad_Ops
(1.0,
333 Data
.Broad_Mult_Operator_Table
,
334 Data
.Broad_Mult_Operand_Table
);
336 if Broad_Actual
/= Broad_Expected
then
337 Report
.Failed
("Wrong result for type Broad multiplication");
342 Broad_Actual
:= Data
.Test_Broad_Ops
(1.0,
343 Data
.Broad_Div_Operator_Table
,
344 Data
.Broad_Div_Operand_Table
);
346 if Broad_Actual
/= Broad_Expected
then
347 Report
.Failed
("Wrong result for type Broad division");
350 ---=---=---=---=---=---=---=---=---=---=---