1 |
149 |
jeremybenn |
-- C46024A.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 FLOATING POINT CONVERSIONS WHEN THE TARGET TYPE IS A
|
27 |
|
|
-- FIXED POINT TYPE, FOR DIGITS 5.
|
28 |
|
|
|
29 |
|
|
-- HISTORY:
|
30 |
|
|
-- JET 02/19/88 CREATED ORIGINAL TEST.
|
31 |
|
|
|
32 |
|
|
WITH REPORT; USE REPORT;
|
33 |
|
|
|
34 |
|
|
PROCEDURE C46024A IS
|
35 |
|
|
|
36 |
|
|
TYPE FLOAT5 IS DIGITS 5;
|
37 |
|
|
TYPE FIX1 IS DELTA 2#0.01# RANGE -16#20.0# .. 16#20.0#;
|
38 |
|
|
TYPE FIX2 IS DELTA 2#0.0001# RANGE -16#80.0# .. 16#80.0#;
|
39 |
|
|
TYPE FIX3 IS DELTA 2#0.000001# RANGE -16#200.0# .. 16#200.0#;
|
40 |
|
|
|
41 |
|
|
F5, F5A, F5B : FLOAT5;
|
42 |
|
|
|
43 |
|
|
GENERIC
|
44 |
|
|
TYPE F IS DELTA <>;
|
45 |
|
|
FUNCTION IDENTG (A : F) RETURN F;
|
46 |
|
|
|
47 |
|
|
FUNCTION IDENTG (A : F) RETURN F IS
|
48 |
|
|
BEGIN
|
49 |
|
|
RETURN A + F(IDENT_INT(0));
|
50 |
|
|
END IDENTG;
|
51 |
|
|
|
52 |
|
|
FUNCTION IDENT1 IS NEW IDENTG(FIX1);
|
53 |
|
|
FUNCTION IDENT2 IS NEW IDENTG(FIX2);
|
54 |
|
|
FUNCTION IDENT3 IS NEW IDENTG(FIX3);
|
55 |
|
|
|
56 |
|
|
BEGIN
|
57 |
|
|
TEST ("C46024A", "CHECK FLOATING POINT CONVERSIONS WHEN THE " &
|
58 |
|
|
"TARGET TYPE IS A FIXED POINT TYPE, FOR " &
|
59 |
|
|
"5-DIGIT PRECISION");
|
60 |
|
|
|
61 |
|
|
IF FIX1(FLOAT5'(2#0.1000_0000_0000_0000_00#E-1)) /=
|
62 |
|
|
IDENT1(2#0.01#) THEN
|
63 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (1)");
|
64 |
|
|
END IF;
|
65 |
|
|
|
66 |
|
|
IF FIX1(FLOAT5'(-2#0.1111_1110_0000_0000_00#E5)) /=
|
67 |
|
|
IDENT1(-2#1_1111.11#) THEN
|
68 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (2)");
|
69 |
|
|
END IF;
|
70 |
|
|
|
71 |
|
|
IF FIX1(FLOAT5'(-2#0.1010_0111_1111_1111_11#E4)) <
|
72 |
|
|
IDENT1(-2#1010.10#) OR
|
73 |
|
|
FIX1(FLOAT5'(-2#0.1010_0111_1111_1111_11#E4)) >
|
74 |
|
|
IDENT1(-2#1010.01#) THEN
|
75 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (3)");
|
76 |
|
|
END IF;
|
77 |
|
|
|
78 |
|
|
IF FIX2(FLOAT5'(-2#0.1000_0000_0000_0000_00#E-3)) /=
|
79 |
|
|
IDENT2(-2#0.0001#) THEN
|
80 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (4)");
|
81 |
|
|
END IF;
|
82 |
|
|
|
83 |
|
|
IF FIX2(FLOAT5'(2#0.1111_1111_1110_0000_00#E7)) /=
|
84 |
|
|
IDENT2(2#111_1111.1111#) THEN
|
85 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (5)");
|
86 |
|
|
END IF;
|
87 |
|
|
|
88 |
|
|
F5 := 2#0.1010_1010_1010_1010_10#E5;
|
89 |
|
|
IF FIX2(F5) < IDENT2(2#1_0101.0101#) OR
|
90 |
|
|
FIX2(F5) > IDENT2(2#1_0101.0110#) THEN
|
91 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (6)");
|
92 |
|
|
END IF;
|
93 |
|
|
|
94 |
|
|
IF FIX3(FLOAT5'(2#0.1000_0000_0000_0000_00#E-5)) /=
|
95 |
|
|
IDENT3(2#0.000001#) THEN
|
96 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (7)");
|
97 |
|
|
END IF;
|
98 |
|
|
|
99 |
|
|
IF FIX3(FLOAT5'(-2#0.1111_1111_1111_1110_00#E9)) /=
|
100 |
|
|
IDENT3(-2#1_1111_1111.1111_11#) THEN
|
101 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (8)");
|
102 |
|
|
END IF;
|
103 |
|
|
|
104 |
|
|
F5 := -2#0.1010_1010_1010_1010_10#E8;
|
105 |
|
|
IF FIX3(F5) < IDENT3(-2#1010_1010.1010_11#) OR
|
106 |
|
|
FIX3(F5) > IDENT3(-2#1010_1010.1010_10#) THEN
|
107 |
|
|
FAILED ("INCORRECT RESULT FROM CONVERSION (9)");
|
108 |
|
|
END IF;
|
109 |
|
|
|
110 |
|
|
F5A := 2#0.1010_1010_1010_1010_10#E4;
|
111 |
|
|
F5B := 2#0.1010_1010_1010_1010_10#E5;
|
112 |
|
|
|
113 |
|
|
IF FIX1(F5A) = IDENT1(2#1010.11#) AND
|
114 |
|
|
FIX1(-F5A) = IDENT1(-2#1010.11#) AND
|
115 |
|
|
FIX1(F5B) = IDENT1(2#1_0101.01#) AND
|
116 |
|
|
FIX1(-F5B) = IDENT1(-2#1_0101.01#) THEN
|
117 |
|
|
COMMENT ("CONVERSION ROUNDS TO NEAREST");
|
118 |
|
|
ELSIF FIX1(F5A) = IDENT1(2#1010.10#) AND
|
119 |
|
|
FIX1(-F5B) = IDENT1(-2#1_0101.10#) THEN
|
120 |
|
|
COMMENT ("CONVERSION ROUNDS TO LEAST FIXED-POINT VALUE");
|
121 |
|
|
ELSIF FIX1(F5B) = IDENT1(2#1_0101.10#) AND
|
122 |
|
|
FIX1(-F5A) = IDENT1(-2#1010.10#) THEN
|
123 |
|
|
COMMENT ("CONVERSION ROUNDS TO GREATEST FIXED-POINT VALUE");
|
124 |
|
|
ELSIF FIX1(F5A) = IDENT1(2#1010.10#) AND
|
125 |
|
|
FIX1(-F5A) = IDENT1(-2#1010.10#) THEN
|
126 |
|
|
COMMENT ("CONVERSION ROUNDS TOWARD ZERO");
|
127 |
|
|
ELSIF FIX1(F5B) = IDENT1(2#1_0101.10#) AND
|
128 |
|
|
FIX1(-F5B) = IDENT1(-2#1_0101.10#) THEN
|
129 |
|
|
COMMENT ("CONVERSION ROUNDS AWAY FROM ZERO");
|
130 |
|
|
ELSE
|
131 |
|
|
COMMENT ("UNABLE TO DETERMINE CONVERSION PATTERN");
|
132 |
|
|
END IF;
|
133 |
|
|
|
134 |
|
|
RESULT;
|
135 |
|
|
|
136 |
|
|
END C46024A;
|