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 multiplication and division of decimal fixed point
28 -- numbers produce exact results.
31 -- Check that multiplication and division of decimal fixed point
32 -- numbers produce exact results.
34 -- SPECIAL REQUIREMENTS
35 -- The Strict Mode for the numerical accuracy must be
36 -- selected. The method by which this mode is selected
37 -- is implementation dependent.
39 -- APPLICABILITY CRITERIA:
40 -- This test applies only to implementations supporting the
42 -- This test only applies to the Strict Mode for numerical
44 -- This test applies only to implementations supporting
45 -- decimal fixed point types of at least 9 digits.
49 -- 3 Apr 96 SAIC Initial release for 2.1
56 Verbose
: constant Boolean := False;
59 Num_Digits
: constant := 6;
60 type Pennies
is delta 0.01 digits Num_Digits
;
61 type Franklins
is delta 100.0 digits Num_Digits
;
62 type Dollars
is delta 1.0 digits Num_Digits
;
68 -- optimization thwarting functions
70 function P
(X
: Pennies
) return Pennies
is
72 if Report
.Ident_Bool
(True) then
75 return 3.21; -- never executed
80 function F
(X
: Franklins
) return Franklins
is
82 if Report
.Ident_Bool
(True) then
85 return 32100.0; -- never executed
90 function D
(X
: Dollars
) return Dollars
is
92 if Report
.Ident_Bool
(True) then
95 return 321.0; -- never executed
101 -- multiplication where one operand is universal real
103 P1
:= P
(0.05) * 200.0;
105 Report
.Failed
("1 - expected 10.00 got " & Pennies
'Image (P1
));
108 D1
:= P
(0.05) * 100.0;
110 Report
.Failed
("2 - expected 5.00 got " & Dollars
'Image (D1
));
113 F1
:= P
(0.05) * 50_000
.0
;
114 if F1
/= 2500.00 then
115 Report
.Failed
("3 - expected 2500.0 got " & Franklins
'Image (F1
));
118 -- multiplication where both operands are decimal fixed
120 P1
:= P
(0.05) * D
(-200.0);
122 Report
.Failed
("4 - expected -10.00 got " & Pennies
'Image (P1
));
125 D1
:= P
(0.05) * P
(-100.0);
127 Report
.Failed
("5 - expected -5.00 got " & Dollars
'Image (D1
));
130 F1
:= P
(-0.05) * F
(50_000
.0
);
131 if F1
/= -2500.00 then
132 Report
.Failed
("6 - expected -2500.0 got " & Franklins
'Image (F1
));
135 -- division where one operand is universal real
137 P1
:= P
(0.05) / 0.001;
139 Report
.Failed
("7 - expected 50.00 got " & Pennies
'Image (P1
));
142 D1
:= D
(1000.0) / 3.0;
144 Report
.Failed
("8 - expected 333.00 got " & Dollars
'Image (D1
));
147 F1
:= P
(1234.56) / 0.0001;
148 if F1
/= 12345600.00 then
149 Report
.Failed
("9 - expected 12345600.0 got " & Franklins
'Image (F1
));
153 -- division where both operands are decimal fixed
155 P1
:= P
(0.05) / D
(1.0);
157 Report
.Failed
("10 - expected 0.05 got " & Pennies
'Image (P1
));
160 -- check for truncation toward 0
161 D1
:= P
(-101.00) / P
(2.0);
163 Report
.Failed
("11 - expected -50.00 got " & Dollars
'Image (D1
));
166 P1
:= P
(-102.03) / P
(-0.5);
168 Report
.Failed
("12 - expected 204.06 got " & Pennies
'Image (P1
));
171 F1
:= P
(876.54) / P
(0.03);
172 if F1
/= 29200.00 then
173 Report
.Failed
("13 - expected 29200.0 got " & Franklins
'Image (F1
));
178 Report
.Failed
("unexpected exception in Check_1");
182 type Pennies
is delta<> digits<>;
183 type Dollars
is delta<> digits<>;
184 type Franklins
is delta<> digits<>;
185 procedure Generic_Check
;
186 procedure Generic_Check
is
188 -- the following code is copied directly from the
189 -- above procedure Check_1
195 -- optimization thwarting functions
197 function P
(X
: Pennies
) return Pennies
is
199 if Report
.Ident_Bool
(True) then
202 return 3.21; -- never executed
207 function F
(X
: Franklins
) return Franklins
is
209 if Report
.Ident_Bool
(True) then
212 return 32100.0; -- never executed
217 function D
(X
: Dollars
) return Dollars
is
219 if Report
.Ident_Bool
(True) then
222 return 321.0; -- never executed
228 -- multiplication where one operand is universal real
230 P1
:= P
(0.05) * 200.0;
232 Report
.Failed
("1 - expected 10.00 got " & Pennies
'Image (P1
));
235 D1
:= P
(0.05) * 100.0;
237 Report
.Failed
("2 - expected 5.00 got " & Dollars
'Image (D1
));
240 F1
:= P
(0.05) * 50_000
.0
;
241 if F1
/= 2500.00 then
242 Report
.Failed
("3 - expected 2500.0 got " & Franklins
'Image (F1
));
245 -- multiplication where both operands are decimal fixed
247 P1
:= P
(0.05) * D
(-200.0);
249 Report
.Failed
("4 - expected -10.00 got " & Pennies
'Image (P1
));
252 D1
:= P
(0.05) * P
(-100.0);
254 Report
.Failed
("5 - expected -5.00 got " & Dollars
'Image (D1
));
257 F1
:= P
(-0.05) * F
(50_000
.0
);
258 if F1
/= -2500.00 then
259 Report
.Failed
("6 - expected -2500.0 got " & Franklins
'Image (F1
));
262 -- division where one operand is universal real
264 P1
:= P
(0.05) / 0.001;
266 Report
.Failed
("7 - expected 50.00 got " & Pennies
'Image (P1
));
269 D1
:= D
(1000.0) / 3.0;
271 Report
.Failed
("8 - expected 333.00 got " & Dollars
'Image (D1
));
274 F1
:= P
(1234.56) / 0.0001;
275 if F1
/= 12345600.00 then
276 Report
.Failed
("9 - expected 12345600.0 got " & Franklins
'Image (F1
));
280 -- division where both operands are decimal fixed
282 P1
:= P
(0.05) / D
(1.0);
284 Report
.Failed
("10 - expected 0.05 got " & Pennies
'Image (P1
));
287 -- check for truncation toward 0
288 D1
:= P
(-101.00) / P
(2.0);
290 Report
.Failed
("11 - expected -50.00 got " & Dollars
'Image (D1
));
293 P1
:= P
(-102.03) / P
(-0.5);
295 Report
.Failed
("12 - expected 204.06 got " & Pennies
'Image (P1
));
298 F1
:= P
(876.54) / P
(0.03);
299 if F1
/= 29200.00 then
300 Report
.Failed
("13 - expected 29200.0 got " & Franklins
'Image (F1
));
306 procedure Check_G6
is
307 Num_Digits
: constant := 6;
308 type Pennies
is delta 0.01 digits Num_Digits
;
309 type Franklins
is delta 100.0 digits Num_Digits
;
310 type Dollars
is delta 1.0 digits Num_Digits
;
312 procedure G
is new Generic_Check
(Pennies
, Dollars
, Franklins
);
318 procedure Check_G9
is
319 Num_Digits
: constant := 9;
320 type Pennies
is delta 0.01 digits Num_Digits
;
321 type Franklins
is delta 100.0 digits Num_Digits
;
322 type Dollars
is delta 1.0 digits Num_Digits
;
324 procedure G
is new Generic_Check
(Pennies
, Dollars
, Franklins
);
331 Report
.Test
("CXG2023",
332 "Check the accuracy of multiplication and division" &
333 " of decimal fixed point numbers");
336 Report
.Comment
("starting Check_1");
341 Report
.Comment
("starting Check_G6");
346 Report
.Comment
("starting Check_G9");