|
1 ------------------------------------------------------------------------ |
|
2 -- dqToIntegral.decTest -- round Quad to integral value -- |
|
3 -- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. -- |
|
4 ------------------------------------------------------------------------ |
|
5 -- Please see the document "General Decimal Arithmetic Testcases" -- |
|
6 -- at http://www2.hursley.ibm.com/decimal for the description of -- |
|
7 -- these testcases. -- |
|
8 -- -- |
|
9 -- These testcases are experimental ('beta' versions), and they -- |
|
10 -- may contain errors. They are offered on an as-is basis. In -- |
|
11 -- particular, achieving the same results as the tests here is not -- |
|
12 -- a guarantee that an implementation complies with any Standard -- |
|
13 -- or specification. The tests are not exhaustive. -- |
|
14 -- -- |
|
15 -- Please send comments, suggestions, and corrections to the author: -- |
|
16 -- Mike Cowlishaw, IBM Fellow -- |
|
17 -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- |
|
18 -- mfc@uk.ibm.com -- |
|
19 ------------------------------------------------------------------------ |
|
20 version: 2.58 |
|
21 |
|
22 -- This set of tests tests the extended specification 'round-to-integral |
|
23 -- value-exact' operations (from IEEE 854, later modified in 754r). |
|
24 -- All non-zero results are defined as being those from either copy or |
|
25 -- quantize, so those are assumed to have been tested extensively |
|
26 -- elsewhere; the tests here are for integrity, rounding mode, etc. |
|
27 -- Also, it is assumed the test harness will use these tests for both |
|
28 -- ToIntegralExact (which does set Inexact) and the fixed-name |
|
29 -- functions (which do not set Inexact). |
|
30 |
|
31 -- Note that decNumber implements an earlier definition of toIntegral |
|
32 -- which never sets Inexact; the decTest operator for that is called |
|
33 -- 'tointegral' instead of 'tointegralx'. |
|
34 |
|
35 extended: 1 |
|
36 clamp: 1 |
|
37 precision: 34 |
|
38 maxExponent: 6144 |
|
39 minExponent: -6143 |
|
40 rounding: half_even |
|
41 |
|
42 dqintx001 tointegralx 0 -> 0 |
|
43 dqintx002 tointegralx 0.0 -> 0 |
|
44 dqintx003 tointegralx 0.1 -> 0 Inexact Rounded |
|
45 dqintx004 tointegralx 0.2 -> 0 Inexact Rounded |
|
46 dqintx005 tointegralx 0.3 -> 0 Inexact Rounded |
|
47 dqintx006 tointegralx 0.4 -> 0 Inexact Rounded |
|
48 dqintx007 tointegralx 0.5 -> 0 Inexact Rounded |
|
49 dqintx008 tointegralx 0.6 -> 1 Inexact Rounded |
|
50 dqintx009 tointegralx 0.7 -> 1 Inexact Rounded |
|
51 dqintx010 tointegralx 0.8 -> 1 Inexact Rounded |
|
52 dqintx011 tointegralx 0.9 -> 1 Inexact Rounded |
|
53 dqintx012 tointegralx 1 -> 1 |
|
54 dqintx013 tointegralx 1.0 -> 1 Rounded |
|
55 dqintx014 tointegralx 1.1 -> 1 Inexact Rounded |
|
56 dqintx015 tointegralx 1.2 -> 1 Inexact Rounded |
|
57 dqintx016 tointegralx 1.3 -> 1 Inexact Rounded |
|
58 dqintx017 tointegralx 1.4 -> 1 Inexact Rounded |
|
59 dqintx018 tointegralx 1.5 -> 2 Inexact Rounded |
|
60 dqintx019 tointegralx 1.6 -> 2 Inexact Rounded |
|
61 dqintx020 tointegralx 1.7 -> 2 Inexact Rounded |
|
62 dqintx021 tointegralx 1.8 -> 2 Inexact Rounded |
|
63 dqintx022 tointegralx 1.9 -> 2 Inexact Rounded |
|
64 -- negatives |
|
65 dqintx031 tointegralx -0 -> -0 |
|
66 dqintx032 tointegralx -0.0 -> -0 |
|
67 dqintx033 tointegralx -0.1 -> -0 Inexact Rounded |
|
68 dqintx034 tointegralx -0.2 -> -0 Inexact Rounded |
|
69 dqintx035 tointegralx -0.3 -> -0 Inexact Rounded |
|
70 dqintx036 tointegralx -0.4 -> -0 Inexact Rounded |
|
71 dqintx037 tointegralx -0.5 -> -0 Inexact Rounded |
|
72 dqintx038 tointegralx -0.6 -> -1 Inexact Rounded |
|
73 dqintx039 tointegralx -0.7 -> -1 Inexact Rounded |
|
74 dqintx040 tointegralx -0.8 -> -1 Inexact Rounded |
|
75 dqintx041 tointegralx -0.9 -> -1 Inexact Rounded |
|
76 dqintx042 tointegralx -1 -> -1 |
|
77 dqintx043 tointegralx -1.0 -> -1 Rounded |
|
78 dqintx044 tointegralx -1.1 -> -1 Inexact Rounded |
|
79 dqintx045 tointegralx -1.2 -> -1 Inexact Rounded |
|
80 dqintx046 tointegralx -1.3 -> -1 Inexact Rounded |
|
81 dqintx047 tointegralx -1.4 -> -1 Inexact Rounded |
|
82 dqintx048 tointegralx -1.5 -> -2 Inexact Rounded |
|
83 dqintx049 tointegralx -1.6 -> -2 Inexact Rounded |
|
84 dqintx050 tointegralx -1.7 -> -2 Inexact Rounded |
|
85 dqintx051 tointegralx -1.8 -> -2 Inexact Rounded |
|
86 dqintx052 tointegralx -1.9 -> -2 Inexact Rounded |
|
87 -- next two would be NaN using quantize(x, 0) |
|
88 dqintx053 tointegralx 10E+60 -> 1.0E+61 |
|
89 dqintx054 tointegralx -10E+60 -> -1.0E+61 |
|
90 |
|
91 -- numbers around precision |
|
92 dqintx060 tointegralx '56267E-17' -> '0' Inexact Rounded |
|
93 dqintx061 tointegralx '56267E-5' -> '1' Inexact Rounded |
|
94 dqintx062 tointegralx '56267E-2' -> '563' Inexact Rounded |
|
95 dqintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded |
|
96 dqintx065 tointegralx '56267E-0' -> '56267' |
|
97 dqintx066 tointegralx '56267E+0' -> '56267' |
|
98 dqintx067 tointegralx '56267E+1' -> '5.6267E+5' |
|
99 dqintx068 tointegralx '56267E+9' -> '5.6267E+13' |
|
100 dqintx069 tointegralx '56267E+10' -> '5.6267E+14' |
|
101 dqintx070 tointegralx '56267E+11' -> '5.6267E+15' |
|
102 dqintx071 tointegralx '56267E+12' -> '5.6267E+16' |
|
103 dqintx072 tointegralx '56267E+13' -> '5.6267E+17' |
|
104 dqintx073 tointegralx '1.23E+96' -> '1.23E+96' |
|
105 dqintx074 tointegralx '1.23E+6144' -> #47ffd300000000000000000000000000 Clamped |
|
106 |
|
107 dqintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded |
|
108 dqintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded |
|
109 dqintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded |
|
110 dqintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded |
|
111 dqintx085 tointegralx '-56267E-0' -> '-56267' |
|
112 dqintx086 tointegralx '-56267E+0' -> '-56267' |
|
113 dqintx087 tointegralx '-56267E+1' -> '-5.6267E+5' |
|
114 dqintx088 tointegralx '-56267E+9' -> '-5.6267E+13' |
|
115 dqintx089 tointegralx '-56267E+10' -> '-5.6267E+14' |
|
116 dqintx090 tointegralx '-56267E+11' -> '-5.6267E+15' |
|
117 dqintx091 tointegralx '-56267E+12' -> '-5.6267E+16' |
|
118 dqintx092 tointegralx '-56267E+13' -> '-5.6267E+17' |
|
119 dqintx093 tointegralx '-1.23E+96' -> '-1.23E+96' |
|
120 dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped |
|
121 |
|
122 -- subnormal inputs |
|
123 dqintx100 tointegralx 1E-299 -> 0 Inexact Rounded |
|
124 dqintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded |
|
125 dqintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded |
|
126 dqintx103 tointegralx 0E-299 -> 0 |
|
127 |
|
128 -- specials and zeros |
|
129 dqintx120 tointegralx 'Inf' -> Infinity |
|
130 dqintx121 tointegralx '-Inf' -> -Infinity |
|
131 dqintx122 tointegralx NaN -> NaN |
|
132 dqintx123 tointegralx sNaN -> NaN Invalid_operation |
|
133 dqintx124 tointegralx 0 -> 0 |
|
134 dqintx125 tointegralx -0 -> -0 |
|
135 dqintx126 tointegralx 0.000 -> 0 |
|
136 dqintx127 tointegralx 0.00 -> 0 |
|
137 dqintx128 tointegralx 0.0 -> 0 |
|
138 dqintx129 tointegralx 0 -> 0 |
|
139 dqintx130 tointegralx 0E-3 -> 0 |
|
140 dqintx131 tointegralx 0E-2 -> 0 |
|
141 dqintx132 tointegralx 0E-1 -> 0 |
|
142 dqintx133 tointegralx 0E-0 -> 0 |
|
143 dqintx134 tointegralx 0E+1 -> 0E+1 |
|
144 dqintx135 tointegralx 0E+2 -> 0E+2 |
|
145 dqintx136 tointegralx 0E+3 -> 0E+3 |
|
146 dqintx137 tointegralx 0E+4 -> 0E+4 |
|
147 dqintx138 tointegralx 0E+5 -> 0E+5 |
|
148 dqintx139 tointegralx -0.000 -> -0 |
|
149 dqintx140 tointegralx -0.00 -> -0 |
|
150 dqintx141 tointegralx -0.0 -> -0 |
|
151 dqintx142 tointegralx -0 -> -0 |
|
152 dqintx143 tointegralx -0E-3 -> -0 |
|
153 dqintx144 tointegralx -0E-2 -> -0 |
|
154 dqintx145 tointegralx -0E-1 -> -0 |
|
155 dqintx146 tointegralx -0E-0 -> -0 |
|
156 dqintx147 tointegralx -0E+1 -> -0E+1 |
|
157 dqintx148 tointegralx -0E+2 -> -0E+2 |
|
158 dqintx149 tointegralx -0E+3 -> -0E+3 |
|
159 dqintx150 tointegralx -0E+4 -> -0E+4 |
|
160 dqintx151 tointegralx -0E+5 -> -0E+5 |
|
161 -- propagating NaNs |
|
162 dqintx152 tointegralx NaN808 -> NaN808 |
|
163 dqintx153 tointegralx sNaN080 -> NaN80 Invalid_operation |
|
164 dqintx154 tointegralx -NaN808 -> -NaN808 |
|
165 dqintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation |
|
166 dqintx156 tointegralx -NaN -> -NaN |
|
167 dqintx157 tointegralx -sNaN -> -NaN Invalid_operation |
|
168 |
|
169 -- examples |
|
170 rounding: half_up |
|
171 dqintx200 tointegralx 2.1 -> 2 Inexact Rounded |
|
172 dqintx201 tointegralx 100 -> 100 |
|
173 dqintx202 tointegralx 100.0 -> 100 Rounded |
|
174 dqintx203 tointegralx 101.5 -> 102 Inexact Rounded |
|
175 dqintx204 tointegralx -101.5 -> -102 Inexact Rounded |
|
176 dqintx205 tointegralx 10E+5 -> 1.0E+6 |
|
177 dqintx206 tointegralx 7.89E+77 -> 7.89E+77 |
|
178 dqintx207 tointegralx -Inf -> -Infinity |
|
179 |
|
180 |
|
181 -- all rounding modes |
|
182 rounding: half_even |
|
183 dqintx210 tointegralx 55.5 -> 56 Inexact Rounded |
|
184 dqintx211 tointegralx 56.5 -> 56 Inexact Rounded |
|
185 dqintx212 tointegralx 57.5 -> 58 Inexact Rounded |
|
186 dqintx213 tointegralx -55.5 -> -56 Inexact Rounded |
|
187 dqintx214 tointegralx -56.5 -> -56 Inexact Rounded |
|
188 dqintx215 tointegralx -57.5 -> -58 Inexact Rounded |
|
189 |
|
190 rounding: half_up |
|
191 |
|
192 dqintx220 tointegralx 55.5 -> 56 Inexact Rounded |
|
193 dqintx221 tointegralx 56.5 -> 57 Inexact Rounded |
|
194 dqintx222 tointegralx 57.5 -> 58 Inexact Rounded |
|
195 dqintx223 tointegralx -55.5 -> -56 Inexact Rounded |
|
196 dqintx224 tointegralx -56.5 -> -57 Inexact Rounded |
|
197 dqintx225 tointegralx -57.5 -> -58 Inexact Rounded |
|
198 |
|
199 rounding: half_down |
|
200 |
|
201 dqintx230 tointegralx 55.5 -> 55 Inexact Rounded |
|
202 dqintx231 tointegralx 56.5 -> 56 Inexact Rounded |
|
203 dqintx232 tointegralx 57.5 -> 57 Inexact Rounded |
|
204 dqintx233 tointegralx -55.5 -> -55 Inexact Rounded |
|
205 dqintx234 tointegralx -56.5 -> -56 Inexact Rounded |
|
206 dqintx235 tointegralx -57.5 -> -57 Inexact Rounded |
|
207 |
|
208 rounding: up |
|
209 |
|
210 dqintx240 tointegralx 55.3 -> 56 Inexact Rounded |
|
211 dqintx241 tointegralx 56.3 -> 57 Inexact Rounded |
|
212 dqintx242 tointegralx 57.3 -> 58 Inexact Rounded |
|
213 dqintx243 tointegralx -55.3 -> -56 Inexact Rounded |
|
214 dqintx244 tointegralx -56.3 -> -57 Inexact Rounded |
|
215 dqintx245 tointegralx -57.3 -> -58 Inexact Rounded |
|
216 |
|
217 rounding: down |
|
218 |
|
219 dqintx250 tointegralx 55.7 -> 55 Inexact Rounded |
|
220 dqintx251 tointegralx 56.7 -> 56 Inexact Rounded |
|
221 dqintx252 tointegralx 57.7 -> 57 Inexact Rounded |
|
222 dqintx253 tointegralx -55.7 -> -55 Inexact Rounded |
|
223 dqintx254 tointegralx -56.7 -> -56 Inexact Rounded |
|
224 dqintx255 tointegralx -57.7 -> -57 Inexact Rounded |
|
225 |
|
226 rounding: ceiling |
|
227 |
|
228 dqintx260 tointegralx 55.3 -> 56 Inexact Rounded |
|
229 dqintx261 tointegralx 56.3 -> 57 Inexact Rounded |
|
230 dqintx262 tointegralx 57.3 -> 58 Inexact Rounded |
|
231 dqintx263 tointegralx -55.3 -> -55 Inexact Rounded |
|
232 dqintx264 tointegralx -56.3 -> -56 Inexact Rounded |
|
233 dqintx265 tointegralx -57.3 -> -57 Inexact Rounded |
|
234 |
|
235 rounding: floor |
|
236 |
|
237 dqintx270 tointegralx 55.7 -> 55 Inexact Rounded |
|
238 dqintx271 tointegralx 56.7 -> 56 Inexact Rounded |
|
239 dqintx272 tointegralx 57.7 -> 57 Inexact Rounded |
|
240 dqintx273 tointegralx -55.7 -> -56 Inexact Rounded |
|
241 dqintx274 tointegralx -56.7 -> -57 Inexact Rounded |
|
242 dqintx275 tointegralx -57.7 -> -58 Inexact Rounded |
|
243 |
|
244 -- Int and uInt32 edge values for testing conversions |
|
245 dqintx300 tointegralx -2147483646 -> -2147483646 |
|
246 dqintx301 tointegralx -2147483647 -> -2147483647 |
|
247 dqintx302 tointegralx -2147483648 -> -2147483648 |
|
248 dqintx303 tointegralx -2147483649 -> -2147483649 |
|
249 dqintx304 tointegralx 2147483646 -> 2147483646 |
|
250 dqintx305 tointegralx 2147483647 -> 2147483647 |
|
251 dqintx306 tointegralx 2147483648 -> 2147483648 |
|
252 dqintx307 tointegralx 2147483649 -> 2147483649 |
|
253 dqintx308 tointegralx 4294967294 -> 4294967294 |
|
254 dqintx309 tointegralx 4294967295 -> 4294967295 |
|
255 dqintx310 tointegralx 4294967296 -> 4294967296 |
|
256 dqintx311 tointegralx 4294967297 -> 4294967297 |
|
257 |