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------------------------------------------------------------------------
20version: 2.59
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
35extended:    1
36clamp:       1
37precision:   34
38maxExponent: 6144
39minExponent: -6143
40rounding:    half_even
41
42dqintx001 tointegralx      0     ->  0
43dqintx002 tointegralx      0.0   ->  0
44dqintx003 tointegralx      0.1   ->  0  Inexact Rounded
45dqintx004 tointegralx      0.2   ->  0  Inexact Rounded
46dqintx005 tointegralx      0.3   ->  0  Inexact Rounded
47dqintx006 tointegralx      0.4   ->  0  Inexact Rounded
48dqintx007 tointegralx      0.5   ->  0  Inexact Rounded
49dqintx008 tointegralx      0.6   ->  1  Inexact Rounded
50dqintx009 tointegralx      0.7   ->  1  Inexact Rounded
51dqintx010 tointegralx      0.8   ->  1  Inexact Rounded
52dqintx011 tointegralx      0.9   ->  1  Inexact Rounded
53dqintx012 tointegralx      1     ->  1
54dqintx013 tointegralx      1.0   ->  1  Rounded
55dqintx014 tointegralx      1.1   ->  1  Inexact Rounded
56dqintx015 tointegralx      1.2   ->  1  Inexact Rounded
57dqintx016 tointegralx      1.3   ->  1  Inexact Rounded
58dqintx017 tointegralx      1.4   ->  1  Inexact Rounded
59dqintx018 tointegralx      1.5   ->  2  Inexact Rounded
60dqintx019 tointegralx      1.6   ->  2  Inexact Rounded
61dqintx020 tointegralx      1.7   ->  2  Inexact Rounded
62dqintx021 tointegralx      1.8   ->  2  Inexact Rounded
63dqintx022 tointegralx      1.9   ->  2  Inexact Rounded
64-- negatives
65dqintx031 tointegralx     -0     -> -0
66dqintx032 tointegralx     -0.0   -> -0
67dqintx033 tointegralx     -0.1   -> -0  Inexact Rounded
68dqintx034 tointegralx     -0.2   -> -0  Inexact Rounded
69dqintx035 tointegralx     -0.3   -> -0  Inexact Rounded
70dqintx036 tointegralx     -0.4   -> -0  Inexact Rounded
71dqintx037 tointegralx     -0.5   -> -0  Inexact Rounded
72dqintx038 tointegralx     -0.6   -> -1  Inexact Rounded
73dqintx039 tointegralx     -0.7   -> -1  Inexact Rounded
74dqintx040 tointegralx     -0.8   -> -1  Inexact Rounded
75dqintx041 tointegralx     -0.9   -> -1  Inexact Rounded
76dqintx042 tointegralx     -1     -> -1
77dqintx043 tointegralx     -1.0   -> -1  Rounded
78dqintx044 tointegralx     -1.1   -> -1  Inexact Rounded
79dqintx045 tointegralx     -1.2   -> -1  Inexact Rounded
80dqintx046 tointegralx     -1.3   -> -1  Inexact Rounded
81dqintx047 tointegralx     -1.4   -> -1  Inexact Rounded
82dqintx048 tointegralx     -1.5   -> -2  Inexact Rounded
83dqintx049 tointegralx     -1.6   -> -2  Inexact Rounded
84dqintx050 tointegralx     -1.7   -> -2  Inexact Rounded
85dqintx051 tointegralx     -1.8   -> -2  Inexact Rounded
86dqintx052 tointegralx     -1.9   -> -2  Inexact Rounded
87-- next two would be NaN using quantize(x, 0)
88dqintx053 tointegralx    10E+60  -> 1.0E+61
89dqintx054 tointegralx   -10E+60  -> -1.0E+61
90
91-- numbers around precision
92dqintx060 tointegralx '56267E-17'   -> '0'      Inexact Rounded
93dqintx061 tointegralx '56267E-5'    -> '1'      Inexact Rounded
94dqintx062 tointegralx '56267E-2'    -> '563'    Inexact Rounded
95dqintx063 tointegralx '56267E-1'    -> '5627'   Inexact Rounded
96dqintx065 tointegralx '56267E-0'    -> '56267'
97dqintx066 tointegralx '56267E+0'    -> '56267'
98dqintx067 tointegralx '56267E+1'    -> '5.6267E+5'
99dqintx068 tointegralx '56267E+9'    -> '5.6267E+13'
100dqintx069 tointegralx '56267E+10'   -> '5.6267E+14'
101dqintx070 tointegralx '56267E+11'   -> '5.6267E+15'
102dqintx071 tointegralx '56267E+12'   -> '5.6267E+16'
103dqintx072 tointegralx '56267E+13'   -> '5.6267E+17'
104dqintx073 tointegralx '1.23E+96'    -> '1.23E+96'
105dqintx074 tointegralx '1.23E+6144'  -> #47ffd300000000000000000000000000 Clamped
106
107dqintx080 tointegralx '-56267E-10'  -> '-0'      Inexact Rounded
108dqintx081 tointegralx '-56267E-5'   -> '-1'      Inexact Rounded
109dqintx082 tointegralx '-56267E-2'   -> '-563'    Inexact Rounded
110dqintx083 tointegralx '-56267E-1'   -> '-5627'   Inexact Rounded
111dqintx085 tointegralx '-56267E-0'   -> '-56267'
112dqintx086 tointegralx '-56267E+0'   -> '-56267'
113dqintx087 tointegralx '-56267E+1'   -> '-5.6267E+5'
114dqintx088 tointegralx '-56267E+9'   -> '-5.6267E+13'
115dqintx089 tointegralx '-56267E+10'  -> '-5.6267E+14'
116dqintx090 tointegralx '-56267E+11'  -> '-5.6267E+15'
117dqintx091 tointegralx '-56267E+12'  -> '-5.6267E+16'
118dqintx092 tointegralx '-56267E+13'  -> '-5.6267E+17'
119dqintx093 tointegralx '-1.23E+96'   -> '-1.23E+96'
120dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped
121
122-- subnormal inputs
123dqintx100 tointegralx        1E-299 -> 0  Inexact Rounded
124dqintx101 tointegralx      0.1E-299 -> 0  Inexact Rounded
125dqintx102 tointegralx     0.01E-299 -> 0  Inexact Rounded
126dqintx103 tointegralx        0E-299 -> 0
127
128-- specials and zeros
129dqintx120 tointegralx 'Inf'       ->  Infinity
130dqintx121 tointegralx '-Inf'      -> -Infinity
131dqintx122 tointegralx   NaN       ->  NaN
132dqintx123 tointegralx  sNaN       ->  NaN  Invalid_operation
133dqintx124 tointegralx     0       ->  0
134dqintx125 tointegralx    -0       -> -0
135dqintx126 tointegralx     0.000   ->  0
136dqintx127 tointegralx     0.00    ->  0
137dqintx128 tointegralx     0.0     ->  0
138dqintx129 tointegralx     0       ->  0
139dqintx130 tointegralx     0E-3    ->  0
140dqintx131 tointegralx     0E-2    ->  0
141dqintx132 tointegralx     0E-1    ->  0
142dqintx133 tointegralx     0E-0    ->  0
143dqintx134 tointegralx     0E+1    ->  0E+1
144dqintx135 tointegralx     0E+2    ->  0E+2
145dqintx136 tointegralx     0E+3    ->  0E+3
146dqintx137 tointegralx     0E+4    ->  0E+4
147dqintx138 tointegralx     0E+5    ->  0E+5
148dqintx139 tointegralx    -0.000   -> -0
149dqintx140 tointegralx    -0.00    -> -0
150dqintx141 tointegralx    -0.0     -> -0
151dqintx142 tointegralx    -0       -> -0
152dqintx143 tointegralx    -0E-3    -> -0
153dqintx144 tointegralx    -0E-2    -> -0
154dqintx145 tointegralx    -0E-1    -> -0
155dqintx146 tointegralx    -0E-0    -> -0
156dqintx147 tointegralx    -0E+1    -> -0E+1
157dqintx148 tointegralx    -0E+2    -> -0E+2
158dqintx149 tointegralx    -0E+3    -> -0E+3
159dqintx150 tointegralx    -0E+4    -> -0E+4
160dqintx151 tointegralx    -0E+5    -> -0E+5
161-- propagating NaNs
162dqintx152 tointegralx   NaN808    ->  NaN808
163dqintx153 tointegralx  sNaN080    ->  NaN80  Invalid_operation
164dqintx154 tointegralx  -NaN808    -> -NaN808
165dqintx155 tointegralx -sNaN080    -> -NaN80  Invalid_operation
166dqintx156 tointegralx  -NaN       -> -NaN
167dqintx157 tointegralx -sNaN       -> -NaN    Invalid_operation
168
169-- examples
170rounding:    half_up
171dqintx200 tointegralx     2.1    -> 2            Inexact Rounded
172dqintx201 tointegralx   100      -> 100
173dqintx202 tointegralx   100.0    -> 100          Rounded
174dqintx203 tointegralx   101.5    -> 102          Inexact Rounded
175dqintx204 tointegralx  -101.5    -> -102         Inexact Rounded
176dqintx205 tointegralx   10E+5    -> 1.0E+6
177dqintx206 tointegralx  7.89E+77  -> 7.89E+77
178dqintx207 tointegralx   -Inf     -> -Infinity
179
180
181-- all rounding modes
182rounding:    half_even
183dqintx210 tointegralx     55.5   ->  56  Inexact Rounded
184dqintx211 tointegralx     56.5   ->  56  Inexact Rounded
185dqintx212 tointegralx     57.5   ->  58  Inexact Rounded
186dqintx213 tointegralx    -55.5   -> -56  Inexact Rounded
187dqintx214 tointegralx    -56.5   -> -56  Inexact Rounded
188dqintx215 tointegralx    -57.5   -> -58  Inexact Rounded
189
190rounding:    half_up
191
192dqintx220 tointegralx     55.5   ->  56  Inexact Rounded
193dqintx221 tointegralx     56.5   ->  57  Inexact Rounded
194dqintx222 tointegralx     57.5   ->  58  Inexact Rounded
195dqintx223 tointegralx    -55.5   -> -56  Inexact Rounded
196dqintx224 tointegralx    -56.5   -> -57  Inexact Rounded
197dqintx225 tointegralx    -57.5   -> -58  Inexact Rounded
198
199rounding:    half_down
200
201dqintx230 tointegralx     55.5   ->  55  Inexact Rounded
202dqintx231 tointegralx     56.5   ->  56  Inexact Rounded
203dqintx232 tointegralx     57.5   ->  57  Inexact Rounded
204dqintx233 tointegralx    -55.5   -> -55  Inexact Rounded
205dqintx234 tointegralx    -56.5   -> -56  Inexact Rounded
206dqintx235 tointegralx    -57.5   -> -57  Inexact Rounded
207
208rounding:    up
209
210dqintx240 tointegralx     55.3   ->  56  Inexact Rounded
211dqintx241 tointegralx     56.3   ->  57  Inexact Rounded
212dqintx242 tointegralx     57.3   ->  58  Inexact Rounded
213dqintx243 tointegralx    -55.3   -> -56  Inexact Rounded
214dqintx244 tointegralx    -56.3   -> -57  Inexact Rounded
215dqintx245 tointegralx    -57.3   -> -58  Inexact Rounded
216
217rounding:    down
218
219dqintx250 tointegralx     55.7   ->  55  Inexact Rounded
220dqintx251 tointegralx     56.7   ->  56  Inexact Rounded
221dqintx252 tointegralx     57.7   ->  57  Inexact Rounded
222dqintx253 tointegralx    -55.7   -> -55  Inexact Rounded
223dqintx254 tointegralx    -56.7   -> -56  Inexact Rounded
224dqintx255 tointegralx    -57.7   -> -57  Inexact Rounded
225
226rounding:    ceiling
227
228dqintx260 tointegralx     55.3   ->  56  Inexact Rounded
229dqintx261 tointegralx     56.3   ->  57  Inexact Rounded
230dqintx262 tointegralx     57.3   ->  58  Inexact Rounded
231dqintx263 tointegralx    -55.3   -> -55  Inexact Rounded
232dqintx264 tointegralx    -56.3   -> -56  Inexact Rounded
233dqintx265 tointegralx    -57.3   -> -57  Inexact Rounded
234
235rounding:    floor
236
237dqintx270 tointegralx     55.7   ->  55  Inexact Rounded
238dqintx271 tointegralx     56.7   ->  56  Inexact Rounded
239dqintx272 tointegralx     57.7   ->  57  Inexact Rounded
240dqintx273 tointegralx    -55.7   -> -56  Inexact Rounded
241dqintx274 tointegralx    -56.7   -> -57  Inexact Rounded
242dqintx275 tointegralx    -57.7   -> -58  Inexact Rounded
243
244-- Int and uInt32 edge values for testing conversions
245dqintx300 tointegralx -2147483646  -> -2147483646
246dqintx301 tointegralx -2147483647  -> -2147483647
247dqintx302 tointegralx -2147483648  -> -2147483648
248dqintx303 tointegralx -2147483649  -> -2147483649
249dqintx304 tointegralx  2147483646  ->  2147483646
250dqintx305 tointegralx  2147483647  ->  2147483647
251dqintx306 tointegralx  2147483648  ->  2147483648
252dqintx307 tointegralx  2147483649  ->  2147483649
253dqintx308 tointegralx  4294967294  ->  4294967294
254dqintx309 tointegralx  4294967295  ->  4294967295
255dqintx310 tointegralx  4294967296  ->  4294967296
256dqintx311 tointegralx  4294967297  ->  4294967297
257
258