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
28 -- and binary fixed point numbers that result in a
29 -- decimal fixed point type produce acceptable results.
32 -- Multiplication and division of mixed binary and decimal
33 -- values are performed. Identity functions are used so
34 -- that the operands of the expressions will not be seen
35 -- as static by the compiler.
37 -- SPECIAL REQUIREMENTS
38 -- The Strict Mode for the numerical accuracy must be
39 -- selected. The method by which this mode is selected
40 -- is implementation dependent.
42 -- APPLICABILITY CRITERIA:
43 -- This test applies only to implementations supporting the
45 -- This test only applies to the Strict Mode for numerical
47 -- This test applies only to implementations supporting
48 -- decimal fixed point types of at least 9 digits.
52 -- 4 Apr 96 SAIC Initial release for 2.1
53 -- 17 Aug 96 SAIC Removed checks for close results
62 Num_Digits
: constant := 9;
63 type Pennies
is delta 0.01 digits Num_Digits
;
64 type Dollars
is delta 1.0 digits Num_Digits
;
66 type Signed_Sixteenths
is delta 0.0625
67 range -2.0 ** (System
.Max_Mantissa
-5) ..
68 2.0 ** (System
.Max_Mantissa
-5) - 1.0;
69 type Unsigned_Sixteenths
is delta 0.0625
70 range 0.0 .. 2.0 ** (System
.Max_Mantissa
-4) - 1.0;
75 -- optimization thwarting functions
77 function P
(X
: Pennies
) return Pennies
is
79 if Report
.Ident_Bool
(True) then
82 return 3.21; -- never executed
87 function D
(X
: Dollars
) return Dollars
is
89 if Report
.Ident_Bool
(True) then
92 return 321.0; -- never executed
97 function US
(X
: Unsigned_Sixteenths
) return Unsigned_Sixteenths
is
99 if Report
.Ident_Bool
(True) then
102 return 321.0; -- never executed
107 function SS
(X
: Signed_Sixteenths
) return Signed_Sixteenths
is
109 if Report
.Ident_Bool
(True) then
112 return 321.0; -- never executed
119 P1
:= P
(0.05) * SS
(-200.0);
121 Report
.Failed
("1 - expected -10.00 got " & Pennies
'Image (P1
));
124 D1
:= P
(0.05) * SS
(-100.0);
126 Report
.Failed
("2 - expected -5.00 got " & Dollars
'Image (D1
));
129 P1
:= P
(0.05) * US
(200.0);
131 Report
.Failed
("3 - expected 10.00 got " & Pennies
'Image (P1
));
134 D1
:= P
(-0.05) * US
(100.0);
136 Report
.Failed
("4 - expected -5.00 got " & Dollars
'Image (D1
));
141 P1
:= P
(0.05) / US
(1.0);
143 Report
.Failed
("6 - expected 0.05 got " & Pennies
'Image (P1
));
149 D1
:= Dollars
'Round (Pennies
(P
(-101.00) / US
(2.0)));
151 Report
.Failed
("11 - expected -51.00 got " & Dollars
'Image (D1
));
154 D1
:= Dollars
'Round (Pennies
(P
(101.00) / US
(2.0)));
156 Report
.Failed
("12 - expected 51.00 got " & Dollars
'Image (D1
));
159 D1
:= Dollars
'Round (Pennies
(SS
(-101.00) / P
(2.0)));
161 Report
.Failed
("13 - expected -51.00 got " & Dollars
'Image (D1
));
164 D1
:= Dollars
'Round (Pennies
(US
(101.00) / P
(2.0)));
166 Report
.Failed
("14 - expected 51.00 got " & Dollars
'Image (D1
));
171 P1
:= P
(-102.03) / SS
(-0.5);
173 Report
.Failed
("15 - expected 204.06 got " & Pennies
'Image (P1
));
179 Report
.Failed
("unexpected exception in Do_Check");
184 Report
.Test
("CXG2024",
185 "Check the accuracy of multiplication and division" &
186 " of mixed decimal and binary fixed point numbers");