1------------------------------------------------------------------------
2-- quantize.decTest -- decimal quantize operation                     --
3-- Copyright (c) IBM Corporation, 1981, 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-- Most of the tests here assume a "regular pattern", where the
23-- sign and coefficient are +1.
24-- 2004.03.15 Underflow for quantize is suppressed
25-- 2005.06.08 More extensive tests for 'does not fit'
26
27extended:    1
28precision:   9
29rounding:    half_up
30maxExponent: 999
31minexponent: -999
32
33-- sanity checks
34quax001 quantize 0       1e0   -> 0
35quax002 quantize 1       1e0   -> 1
36quax003 quantize 0.1    1e+2   -> 0E+2 Inexact Rounded
37quax005 quantize 0.1    1e+1   -> 0E+1 Inexact Rounded
38quax006 quantize 0.1     1e0   -> 0 Inexact Rounded
39quax007 quantize 0.1    1e-1   -> 0.1
40quax008 quantize 0.1    1e-2   -> 0.10
41quax009 quantize 0.1    1e-3   -> 0.100
42quax010 quantize 0.9    1e+2   -> 0E+2 Inexact Rounded
43quax011 quantize 0.9    1e+1   -> 0E+1 Inexact Rounded
44quax012 quantize 0.9    1e+0   -> 1 Inexact Rounded
45quax013 quantize 0.9    1e-1   -> 0.9
46quax014 quantize 0.9    1e-2   -> 0.90
47quax015 quantize 0.9    1e-3   -> 0.900
48-- negatives
49quax021 quantize -0      1e0   -> -0
50quax022 quantize -1      1e0   -> -1
51quax023 quantize -0.1   1e+2   -> -0E+2 Inexact Rounded
52quax025 quantize -0.1   1e+1   -> -0E+1 Inexact Rounded
53quax026 quantize -0.1    1e0   -> -0 Inexact Rounded
54quax027 quantize -0.1   1e-1   -> -0.1
55quax028 quantize -0.1   1e-2   -> -0.10
56quax029 quantize -0.1   1e-3   -> -0.100
57quax030 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
58quax031 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
59quax032 quantize -0.9   1e+0   -> -1 Inexact Rounded
60quax033 quantize -0.9   1e-1   -> -0.9
61quax034 quantize -0.9   1e-2   -> -0.90
62quax035 quantize -0.9   1e-3   -> -0.900
63quax036 quantize -0.5   1e+2   -> -0E+2 Inexact Rounded
64quax037 quantize -0.5   1e+1   -> -0E+1 Inexact Rounded
65quax038 quantize -0.5   1e+0   -> -1 Inexact Rounded
66quax039 quantize -0.5   1e-1   -> -0.5
67quax040 quantize -0.5   1e-2   -> -0.50
68quax041 quantize -0.5   1e-3   -> -0.500
69quax042 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
70quax043 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
71quax044 quantize -0.9   1e+0   -> -1 Inexact Rounded
72quax045 quantize -0.9   1e-1   -> -0.9
73quax046 quantize -0.9   1e-2   -> -0.90
74quax047 quantize -0.9   1e-3   -> -0.900
75
76-- examples from Specification
77quax060 quantize 2.17   0.001  -> 2.170
78quax061 quantize 2.17   0.01   -> 2.17
79quax062 quantize 2.17   0.1    -> 2.2 Inexact Rounded
80quax063 quantize 2.17   1e+0   -> 2 Inexact Rounded
81quax064 quantize 2.17   1e+1   -> 0E+1 Inexact Rounded
82quax065 quantize -Inf    Inf   -> -Infinity
83quax066 quantize 2       Inf   -> NaN Invalid_operation
84quax067 quantize -0.1    1     -> -0 Inexact Rounded
85quax068 quantize -0      1e+5     -> -0E+5
86quax069 quantize +35236450.6 1e-2 -> NaN Invalid_operation
87quax070 quantize -35236450.6 1e-2 -> NaN Invalid_operation
88quax071 quantize 217    1e-1   -> 217.0
89quax072 quantize 217    1e+0   -> 217
90quax073 quantize 217    1e+1   -> 2.2E+2 Inexact Rounded
91quax074 quantize 217    1e+2   -> 2E+2 Inexact Rounded
92
93-- general tests ..
94quax089 quantize 12     1e+4   -> 0E+4 Inexact Rounded
95quax090 quantize 12     1e+3   -> 0E+3 Inexact Rounded
96quax091 quantize 12     1e+2   -> 0E+2 Inexact Rounded
97quax092 quantize 12     1e+1   -> 1E+1 Inexact Rounded
98quax093 quantize 1.2345 1e-2   -> 1.23 Inexact Rounded
99quax094 quantize 1.2355 1e-2   -> 1.24 Inexact Rounded
100quax095 quantize 1.2345 1e-6   -> 1.234500
101quax096 quantize 9.9999 1e-2   -> 10.00 Inexact Rounded
102quax097 quantize 0.0001 1e-2   -> 0.00 Inexact Rounded
103quax098 quantize 0.001  1e-2   -> 0.00 Inexact Rounded
104quax099 quantize 0.009  1e-2   -> 0.01 Inexact Rounded
105quax100 quantize 92     1e+2   -> 1E+2 Inexact Rounded
106
107quax101 quantize -1      1e0   ->  -1
108quax102 quantize -1     1e-1   ->  -1.0
109quax103 quantize -1     1e-2   ->  -1.00
110quax104 quantize  0      1e0   ->  0
111quax105 quantize  0     1e-1   ->  0.0
112quax106 quantize  0     1e-2   ->  0.00
113quax107 quantize  0.00   1e0   ->  0
114quax108 quantize  0     1e+1   ->  0E+1
115quax109 quantize  0     1e+2   ->  0E+2
116quax110 quantize +1      1e0   ->  1
117quax111 quantize +1     1e-1   ->  1.0
118quax112 quantize +1     1e-2   ->  1.00
119
120quax120 quantize   1.04  1e-3 ->  1.040
121quax121 quantize   1.04  1e-2 ->  1.04
122quax122 quantize   1.04  1e-1 ->  1.0 Inexact Rounded
123quax123 quantize   1.04   1e0 ->  1 Inexact Rounded
124quax124 quantize   1.05  1e-3 ->  1.050
125quax125 quantize   1.05  1e-2 ->  1.05
126quax126 quantize   1.05  1e-1 ->  1.1 Inexact Rounded
127quax131 quantize   1.05   1e0 ->  1 Inexact Rounded
128quax132 quantize   1.06  1e-3 ->  1.060
129quax133 quantize   1.06  1e-2 ->  1.06
130quax134 quantize   1.06  1e-1 ->  1.1 Inexact Rounded
131quax135 quantize   1.06   1e0 ->  1 Inexact Rounded
132
133quax140 quantize   -10    1e-2  ->  -10.00
134quax141 quantize   +1     1e-2  ->  1.00
135quax142 quantize   +10    1e-2  ->  10.00
136quax143 quantize   1E+10  1e-2  ->  NaN Invalid_operation
137quax144 quantize   1E-10  1e-2  ->  0.00 Inexact Rounded
138quax145 quantize   1E-3   1e-2  ->  0.00 Inexact Rounded
139quax146 quantize   1E-2   1e-2  ->  0.01
140quax147 quantize   1E-1   1e-2  ->  0.10
141quax148 quantize   0E-10  1e-2  ->  0.00
142
143quax150 quantize   1.0600 1e-5 ->  1.06000
144quax151 quantize   1.0600 1e-4 ->  1.0600
145quax152 quantize   1.0600 1e-3 ->  1.060 Rounded
146quax153 quantize   1.0600 1e-2 ->  1.06 Rounded
147quax154 quantize   1.0600 1e-1 ->  1.1 Inexact Rounded
148quax155 quantize   1.0600  1e0 ->  1 Inexact Rounded
149
150-- base tests with non-1 coefficients
151quax161 quantize 0      -9e0   -> 0
152quax162 quantize 1      -7e0   -> 1
153quax163 quantize 0.1   -1e+2   -> 0E+2 Inexact Rounded
154quax165 quantize 0.1    0e+1   -> 0E+1 Inexact Rounded
155quax166 quantize 0.1     2e0   -> 0 Inexact Rounded
156quax167 quantize 0.1    3e-1   -> 0.1
157quax168 quantize 0.1   44e-2   -> 0.10
158quax169 quantize 0.1  555e-3   -> 0.100
159quax170 quantize 0.9 6666e+2   -> 0E+2 Inexact Rounded
160quax171 quantize 0.9 -777e+1   -> 0E+1 Inexact Rounded
161quax172 quantize 0.9  -88e+0   -> 1 Inexact Rounded
162quax173 quantize 0.9   -9e-1   -> 0.9
163quax174 quantize 0.9    0e-2   -> 0.90
164quax175 quantize 0.9  1.1e-3   -> 0.9000
165-- negatives
166quax181 quantize -0    1.1e0   -> -0.0
167quax182 quantize -1     -1e0   -> -1
168quax183 quantize -0.1  11e+2   -> -0E+2 Inexact Rounded
169quax185 quantize -0.1 111e+1   -> -0E+1 Inexact Rounded
170quax186 quantize -0.1   71e0   -> -0 Inexact Rounded
171quax187 quantize -0.1 -91e-1   -> -0.1
172quax188 quantize -0.1 -.1e-2   -> -0.100
173quax189 quantize -0.1  -1e-3   -> -0.100
174quax190 quantize -0.9   0e+2   -> -0E+2 Inexact Rounded
175quax191 quantize -0.9  -0e+1   -> -0E+1 Inexact Rounded
176quax192 quantize -0.9 -10e+0   -> -1 Inexact Rounded
177quax193 quantize -0.9 100e-1   -> -0.9
178quax194 quantize -0.9 999e-2   -> -0.90
179
180-- +ve exponents ..
181quax201 quantize   -1   1e+0 ->  -1
182quax202 quantize   -1   1e+1 ->  -0E+1 Inexact Rounded
183quax203 quantize   -1   1e+2 ->  -0E+2 Inexact Rounded
184quax204 quantize    0   1e+0 ->  0
185quax205 quantize    0   1e+1 ->  0E+1
186quax206 quantize    0   1e+2 ->  0E+2
187quax207 quantize   +1   1e+0 ->  1
188quax208 quantize   +1   1e+1 ->  0E+1 Inexact Rounded
189quax209 quantize   +1   1e+2 ->  0E+2 Inexact Rounded
190
191quax220 quantize   1.04 1e+3 ->  0E+3 Inexact Rounded
192quax221 quantize   1.04 1e+2 ->  0E+2 Inexact Rounded
193quax222 quantize   1.04 1e+1 ->  0E+1 Inexact Rounded
194quax223 quantize   1.04 1e+0 ->  1 Inexact Rounded
195quax224 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
196quax225 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
197quax226 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
198quax227 quantize   1.05 1e+0 ->  1 Inexact Rounded
199quax228 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
200quax229 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
201quax230 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
202quax231 quantize   1.05 1e+0 ->  1 Inexact Rounded
203quax232 quantize   1.06 1e+3 ->  0E+3 Inexact Rounded
204quax233 quantize   1.06 1e+2 ->  0E+2 Inexact Rounded
205quax234 quantize   1.06 1e+1 ->  0E+1 Inexact Rounded
206quax235 quantize   1.06 1e+0 ->  1 Inexact Rounded
207
208quax240 quantize   -10   1e+1  ->  -1E+1 Rounded
209quax241 quantize   +1    1e+1  ->  0E+1 Inexact Rounded
210quax242 quantize   +10   1e+1  ->  1E+1 Rounded
211quax243 quantize   1E+1  1e+1  ->  1E+1          -- underneath this is E+1
212quax244 quantize   1E+2  1e+1  ->  1.0E+2        -- underneath this is E+1
213quax245 quantize   1E+3  1e+1  ->  1.00E+3       -- underneath this is E+1
214quax246 quantize   1E+4  1e+1  ->  1.000E+4      -- underneath this is E+1
215quax247 quantize   1E+5  1e+1  ->  1.0000E+5     -- underneath this is E+1
216quax248 quantize   1E+6  1e+1  ->  1.00000E+6    -- underneath this is E+1
217quax249 quantize   1E+7  1e+1  ->  1.000000E+7   -- underneath this is E+1
218quax250 quantize   1E+8  1e+1  ->  1.0000000E+8  -- underneath this is E+1
219quax251 quantize   1E+9  1e+1  ->  1.00000000E+9 -- underneath this is E+1
220-- next one tries to add 9 zeros
221quax252 quantize   1E+10 1e+1  ->  NaN Invalid_operation
222quax253 quantize   1E-10 1e+1  ->  0E+1 Inexact Rounded
223quax254 quantize   1E-2  1e+1  ->  0E+1 Inexact Rounded
224quax255 quantize   0E-10 1e+1  ->  0E+1
225quax256 quantize  -0E-10 1e+1  -> -0E+1
226quax257 quantize  -0E-1  1e+1  -> -0E+1
227quax258 quantize  -0     1e+1  -> -0E+1
228quax259 quantize  -0E+1  1e+1  -> -0E+1
229
230quax260 quantize   -10   1e+2  ->  -0E+2 Inexact Rounded
231quax261 quantize   +1    1e+2  ->  0E+2 Inexact Rounded
232quax262 quantize   +10   1e+2  ->  0E+2 Inexact Rounded
233quax263 quantize   1E+1  1e+2  ->  0E+2 Inexact Rounded
234quax264 quantize   1E+2  1e+2  ->  1E+2
235quax265 quantize   1E+3  1e+2  ->  1.0E+3
236quax266 quantize   1E+4  1e+2  ->  1.00E+4
237quax267 quantize   1E+5  1e+2  ->  1.000E+5
238quax268 quantize   1E+6  1e+2  ->  1.0000E+6
239quax269 quantize   1E+7  1e+2  ->  1.00000E+7
240quax270 quantize   1E+8  1e+2  ->  1.000000E+8
241quax271 quantize   1E+9  1e+2  ->  1.0000000E+9
242quax272 quantize   1E+10 1e+2  ->  1.00000000E+10
243quax273 quantize   1E-10 1e+2  ->  0E+2 Inexact Rounded
244quax274 quantize   1E-2  1e+2  ->  0E+2 Inexact Rounded
245quax275 quantize   0E-10 1e+2  ->  0E+2
246
247quax280 quantize   -10   1e+3  ->  -0E+3 Inexact Rounded
248quax281 quantize   +1    1e+3  ->  0E+3 Inexact Rounded
249quax282 quantize   +10   1e+3  ->  0E+3 Inexact Rounded
250quax283 quantize   1E+1  1e+3  ->  0E+3 Inexact Rounded
251quax284 quantize   1E+2  1e+3  ->  0E+3 Inexact Rounded
252quax285 quantize   1E+3  1e+3  ->  1E+3
253quax286 quantize   1E+4  1e+3  ->  1.0E+4
254quax287 quantize   1E+5  1e+3  ->  1.00E+5
255quax288 quantize   1E+6  1e+3  ->  1.000E+6
256quax289 quantize   1E+7  1e+3  ->  1.0000E+7
257quax290 quantize   1E+8  1e+3  ->  1.00000E+8
258quax291 quantize   1E+9  1e+3  ->  1.000000E+9
259quax292 quantize   1E+10 1e+3  ->  1.0000000E+10
260quax293 quantize   1E-10 1e+3  ->  0E+3 Inexact Rounded
261quax294 quantize   1E-2  1e+3  ->  0E+3 Inexact Rounded
262quax295 quantize   0E-10 1e+3  ->  0E+3
263
264-- round up from below [sign wrong in JIT compiler once]
265quax300 quantize   0.0078 1e-5 ->  0.00780
266quax301 quantize   0.0078 1e-4 ->  0.0078
267quax302 quantize   0.0078 1e-3 ->  0.008 Inexact Rounded
268quax303 quantize   0.0078 1e-2 ->  0.01 Inexact Rounded
269quax304 quantize   0.0078 1e-1 ->  0.0 Inexact Rounded
270quax305 quantize   0.0078  1e0 ->  0 Inexact Rounded
271quax306 quantize   0.0078 1e+1 ->  0E+1 Inexact Rounded
272quax307 quantize   0.0078 1e+2 ->  0E+2 Inexact Rounded
273
274quax310 quantize  -0.0078 1e-5 -> -0.00780
275quax311 quantize  -0.0078 1e-4 -> -0.0078
276quax312 quantize  -0.0078 1e-3 -> -0.008 Inexact Rounded
277quax313 quantize  -0.0078 1e-2 -> -0.01 Inexact Rounded
278quax314 quantize  -0.0078 1e-1 -> -0.0 Inexact Rounded
279quax315 quantize  -0.0078  1e0 -> -0 Inexact Rounded
280quax316 quantize  -0.0078 1e+1 -> -0E+1 Inexact Rounded
281quax317 quantize  -0.0078 1e+2 -> -0E+2 Inexact Rounded
282
283quax320 quantize   0.078 1e-5 ->  0.07800
284quax321 quantize   0.078 1e-4 ->  0.0780
285quax322 quantize   0.078 1e-3 ->  0.078
286quax323 quantize   0.078 1e-2 ->  0.08 Inexact Rounded
287quax324 quantize   0.078 1e-1 ->  0.1 Inexact Rounded
288quax325 quantize   0.078  1e0 ->  0 Inexact Rounded
289quax326 quantize   0.078 1e+1 ->  0E+1 Inexact Rounded
290quax327 quantize   0.078 1e+2 ->  0E+2 Inexact Rounded
291
292quax330 quantize  -0.078 1e-5 -> -0.07800
293quax331 quantize  -0.078 1e-4 -> -0.0780
294quax332 quantize  -0.078 1e-3 -> -0.078
295quax333 quantize  -0.078 1e-2 -> -0.08 Inexact Rounded
296quax334 quantize  -0.078 1e-1 -> -0.1 Inexact Rounded
297quax335 quantize  -0.078  1e0 -> -0 Inexact Rounded
298quax336 quantize  -0.078 1e+1 -> -0E+1 Inexact Rounded
299quax337 quantize  -0.078 1e+2 -> -0E+2 Inexact Rounded
300
301quax340 quantize   0.78 1e-5 ->  0.78000
302quax341 quantize   0.78 1e-4 ->  0.7800
303quax342 quantize   0.78 1e-3 ->  0.780
304quax343 quantize   0.78 1e-2 ->  0.78
305quax344 quantize   0.78 1e-1 ->  0.8 Inexact Rounded
306quax345 quantize   0.78  1e0 ->  1 Inexact Rounded
307quax346 quantize   0.78 1e+1 ->  0E+1 Inexact Rounded
308quax347 quantize   0.78 1e+2 ->  0E+2 Inexact Rounded
309
310quax350 quantize  -0.78 1e-5 -> -0.78000
311quax351 quantize  -0.78 1e-4 -> -0.7800
312quax352 quantize  -0.78 1e-3 -> -0.780
313quax353 quantize  -0.78 1e-2 -> -0.78
314quax354 quantize  -0.78 1e-1 -> -0.8 Inexact Rounded
315quax355 quantize  -0.78  1e0 -> -1 Inexact Rounded
316quax356 quantize  -0.78 1e+1 -> -0E+1 Inexact Rounded
317quax357 quantize  -0.78 1e+2 -> -0E+2 Inexact Rounded
318
319quax360 quantize   7.8 1e-5 ->  7.80000
320quax361 quantize   7.8 1e-4 ->  7.8000
321quax362 quantize   7.8 1e-3 ->  7.800
322quax363 quantize   7.8 1e-2 ->  7.80
323quax364 quantize   7.8 1e-1 ->  7.8
324quax365 quantize   7.8  1e0 ->  8 Inexact Rounded
325quax366 quantize   7.8 1e+1 ->  1E+1 Inexact Rounded
326quax367 quantize   7.8 1e+2 ->  0E+2 Inexact Rounded
327quax368 quantize   7.8 1e+3 ->  0E+3 Inexact Rounded
328
329quax370 quantize  -7.8 1e-5 -> -7.80000
330quax371 quantize  -7.8 1e-4 -> -7.8000
331quax372 quantize  -7.8 1e-3 -> -7.800
332quax373 quantize  -7.8 1e-2 -> -7.80
333quax374 quantize  -7.8 1e-1 -> -7.8
334quax375 quantize  -7.8  1e0 -> -8 Inexact Rounded
335quax376 quantize  -7.8 1e+1 -> -1E+1 Inexact Rounded
336quax377 quantize  -7.8 1e+2 -> -0E+2 Inexact Rounded
337quax378 quantize  -7.8 1e+3 -> -0E+3 Inexact Rounded
338
339-- some individuals
340precision: 9
341quax380 quantize   352364.506 1e-2 -> 352364.51 Inexact Rounded
342quax381 quantize   3523645.06 1e-2 -> 3523645.06
343quax382 quantize   35236450.6 1e-2 -> NaN Invalid_operation
344quax383 quantize   352364506  1e-2 -> NaN Invalid_operation
345quax384 quantize  -352364.506 1e-2 -> -352364.51 Inexact Rounded
346quax385 quantize  -3523645.06 1e-2 -> -3523645.06
347quax386 quantize  -35236450.6 1e-2 -> NaN Invalid_operation
348quax387 quantize  -352364506  1e-2 -> NaN Invalid_operation
349
350rounding: down
351quax389 quantize   35236450.6 1e-2 -> NaN Invalid_operation
352-- ? should that one instead have been:
353-- quax389 quantize   35236450.6 1e-2 -> NaN Invalid_operation
354rounding: half_up
355
356-- and a few more from e-mail discussions
357precision: 7
358quax391 quantize  12.34567  1e-3 -> 12.346   Inexact Rounded
359quax392 quantize  123.4567  1e-3 -> 123.457  Inexact Rounded
360quax393 quantize  1234.567  1e-3 -> 1234.567
361quax394 quantize  12345.67  1e-3 -> NaN Invalid_operation
362quax395 quantize  123456.7  1e-3 -> NaN Invalid_operation
363quax396 quantize  1234567.  1e-3 -> NaN Invalid_operation
364
365-- some 9999 round-up cases
366precision: 9
367quax400 quantize   9.999        1e-5  ->  9.99900
368quax401 quantize   9.999        1e-4  ->  9.9990
369quax402 quantize   9.999        1e-3  ->  9.999
370quax403 quantize   9.999        1e-2  -> 10.00     Inexact Rounded
371quax404 quantize   9.999        1e-1  -> 10.0      Inexact Rounded
372quax405 quantize   9.999         1e0  -> 10        Inexact Rounded
373quax406 quantize   9.999         1e1  -> 1E+1      Inexact Rounded
374quax407 quantize   9.999         1e2  -> 0E+2      Inexact Rounded
375
376quax410 quantize   0.999        1e-5  ->  0.99900
377quax411 quantize   0.999        1e-4  ->  0.9990
378quax412 quantize   0.999        1e-3  ->  0.999
379quax413 quantize   0.999        1e-2  ->  1.00     Inexact Rounded
380quax414 quantize   0.999        1e-1  ->  1.0      Inexact Rounded
381quax415 quantize   0.999         1e0  ->  1        Inexact Rounded
382quax416 quantize   0.999         1e1  -> 0E+1      Inexact Rounded
383
384quax420 quantize   0.0999       1e-5  ->  0.09990
385quax421 quantize   0.0999       1e-4  ->  0.0999
386quax422 quantize   0.0999       1e-3  ->  0.100    Inexact Rounded
387quax423 quantize   0.0999       1e-2  ->  0.10     Inexact Rounded
388quax424 quantize   0.0999       1e-1  ->  0.1      Inexact Rounded
389quax425 quantize   0.0999        1e0  ->  0        Inexact Rounded
390quax426 quantize   0.0999        1e1  -> 0E+1      Inexact Rounded
391
392quax430 quantize   0.00999      1e-5  ->  0.00999
393quax431 quantize   0.00999      1e-4  ->  0.0100   Inexact Rounded
394quax432 quantize   0.00999      1e-3  ->  0.010    Inexact Rounded
395quax433 quantize   0.00999      1e-2  ->  0.01     Inexact Rounded
396quax434 quantize   0.00999      1e-1  ->  0.0      Inexact Rounded
397quax435 quantize   0.00999       1e0  ->  0        Inexact Rounded
398quax436 quantize   0.00999       1e1  -> 0E+1      Inexact Rounded
399
400quax440 quantize   0.000999     1e-5  ->  0.00100  Inexact Rounded
401quax441 quantize   0.000999     1e-4  ->  0.0010   Inexact Rounded
402quax442 quantize   0.000999     1e-3  ->  0.001    Inexact Rounded
403quax443 quantize   0.000999     1e-2  ->  0.00     Inexact Rounded
404quax444 quantize   0.000999     1e-1  ->  0.0      Inexact Rounded
405quax445 quantize   0.000999      1e0  ->  0        Inexact Rounded
406quax446 quantize   0.000999      1e1  -> 0E+1      Inexact Rounded
407
408precision: 8
409quax449 quantize   9.999E-15    1e-23 ->  NaN Invalid_operation
410quax450 quantize   9.999E-15    1e-22 ->  9.9990000E-15
411quax451 quantize   9.999E-15    1e-21 ->  9.999000E-15
412quax452 quantize   9.999E-15    1e-20 ->  9.99900E-15
413quax453 quantize   9.999E-15    1e-19 ->  9.9990E-15
414quax454 quantize   9.999E-15    1e-18 ->  9.999E-15
415quax455 quantize   9.999E-15    1e-17 ->  1.000E-14 Inexact Rounded
416quax456 quantize   9.999E-15    1e-16 ->  1.00E-14  Inexact Rounded
417quax457 quantize   9.999E-15    1e-15 ->  1.0E-14   Inexact Rounded
418quax458 quantize   9.999E-15    1e-14 ->  1E-14     Inexact Rounded
419quax459 quantize   9.999E-15    1e-13 ->  0E-13     Inexact Rounded
420quax460 quantize   9.999E-15    1e-12 ->  0E-12     Inexact Rounded
421quax461 quantize   9.999E-15    1e-11 ->  0E-11     Inexact Rounded
422quax462 quantize   9.999E-15    1e-10 ->  0E-10     Inexact Rounded
423quax463 quantize   9.999E-15     1e-9 ->  0E-9      Inexact Rounded
424quax464 quantize   9.999E-15     1e-8 ->  0E-8      Inexact Rounded
425quax465 quantize   9.999E-15     1e-7 ->  0E-7      Inexact Rounded
426quax466 quantize   9.999E-15     1e-6 ->  0.000000  Inexact Rounded
427quax467 quantize   9.999E-15     1e-5 ->  0.00000   Inexact Rounded
428quax468 quantize   9.999E-15     1e-4 ->  0.0000    Inexact Rounded
429quax469 quantize   9.999E-15     1e-3 ->  0.000     Inexact Rounded
430quax470 quantize   9.999E-15     1e-2 ->  0.00      Inexact Rounded
431quax471 quantize   9.999E-15     1e-1 ->  0.0       Inexact Rounded
432quax472 quantize   9.999E-15      1e0 ->  0         Inexact Rounded
433quax473 quantize   9.999E-15      1e1 ->  0E+1      Inexact Rounded
434
435precision: 7
436quax900 quantize   9.999E-15    1e-22 ->  NaN       Invalid_operation
437quax901 quantize   9.999E-15    1e-21 ->  9.999000E-15
438quax902 quantize   9.999E-15    1e-20 ->  9.99900E-15
439quax903 quantize   9.999E-15    1e-19 ->  9.9990E-15
440quax904 quantize   9.999E-15    1e-18 ->  9.999E-15
441quax905 quantize   9.999E-15    1e-17 ->  1.000E-14 Inexact Rounded
442quax906 quantize   9.999E-15    1e-16 ->  1.00E-14  Inexact Rounded
443quax907 quantize   9.999E-15    1e-15 ->  1.0E-14   Inexact Rounded
444quax908 quantize   9.999E-15    1e-14 ->  1E-14     Inexact Rounded
445quax909 quantize   9.999E-15    1e-13 ->  0E-13     Inexact Rounded
446quax910 quantize   9.999E-15    1e-12 ->  0E-12     Inexact Rounded
447quax911 quantize   9.999E-15    1e-11 ->  0E-11     Inexact Rounded
448quax912 quantize   9.999E-15    1e-10 ->  0E-10     Inexact Rounded
449quax913 quantize   9.999E-15     1e-9 ->  0E-9      Inexact Rounded
450quax914 quantize   9.999E-15     1e-8 ->  0E-8      Inexact Rounded
451quax915 quantize   9.999E-15     1e-7 ->  0E-7      Inexact Rounded
452quax916 quantize   9.999E-15     1e-6 ->  0.000000  Inexact Rounded
453quax917 quantize   9.999E-15     1e-5 ->  0.00000   Inexact Rounded
454quax918 quantize   9.999E-15     1e-4 ->  0.0000    Inexact Rounded
455quax919 quantize   9.999E-15     1e-3 ->  0.000     Inexact Rounded
456quax920 quantize   9.999E-15     1e-2 ->  0.00      Inexact Rounded
457quax921 quantize   9.999E-15     1e-1 ->  0.0       Inexact Rounded
458quax922 quantize   9.999E-15      1e0 ->  0         Inexact Rounded
459quax923 quantize   9.999E-15      1e1 ->  0E+1      Inexact Rounded
460
461precision: 6
462quax930 quantize   9.999E-15    1e-22 ->  NaN       Invalid_operation
463quax931 quantize   9.999E-15    1e-21 ->  NaN       Invalid_operation
464quax932 quantize   9.999E-15    1e-20 ->  9.99900E-15
465quax933 quantize   9.999E-15    1e-19 ->  9.9990E-15
466quax934 quantize   9.999E-15    1e-18 ->  9.999E-15
467quax935 quantize   9.999E-15    1e-17 ->  1.000E-14 Inexact Rounded
468quax936 quantize   9.999E-15    1e-16 ->  1.00E-14  Inexact Rounded
469quax937 quantize   9.999E-15    1e-15 ->  1.0E-14   Inexact Rounded
470quax938 quantize   9.999E-15    1e-14 ->  1E-14     Inexact Rounded
471quax939 quantize   9.999E-15    1e-13 ->  0E-13     Inexact Rounded
472quax940 quantize   9.999E-15    1e-12 ->  0E-12     Inexact Rounded
473quax941 quantize   9.999E-15    1e-11 ->  0E-11     Inexact Rounded
474quax942 quantize   9.999E-15    1e-10 ->  0E-10     Inexact Rounded
475quax943 quantize   9.999E-15     1e-9 ->  0E-9      Inexact Rounded
476quax944 quantize   9.999E-15     1e-8 ->  0E-8      Inexact Rounded
477quax945 quantize   9.999E-15     1e-7 ->  0E-7      Inexact Rounded
478quax946 quantize   9.999E-15     1e-6 ->  0.000000  Inexact Rounded
479quax947 quantize   9.999E-15     1e-5 ->  0.00000   Inexact Rounded
480quax948 quantize   9.999E-15     1e-4 ->  0.0000    Inexact Rounded
481quax949 quantize   9.999E-15     1e-3 ->  0.000     Inexact Rounded
482quax950 quantize   9.999E-15     1e-2 ->  0.00      Inexact Rounded
483quax951 quantize   9.999E-15     1e-1 ->  0.0       Inexact Rounded
484quax952 quantize   9.999E-15      1e0 ->  0         Inexact Rounded
485quax953 quantize   9.999E-15      1e1 ->  0E+1      Inexact Rounded
486
487precision: 3
488quax960 quantize   9.999E-15    1e-22 ->  NaN       Invalid_operation
489quax961 quantize   9.999E-15    1e-21 ->  NaN       Invalid_operation
490quax962 quantize   9.999E-15    1e-20 ->  NaN       Invalid_operation
491quax963 quantize   9.999E-15    1e-19 ->  NaN       Invalid_operation
492quax964 quantize   9.999E-15    1e-18 ->  NaN       Invalid_operation
493quax965 quantize   9.999E-15    1e-17 ->  NaN       Invalid_operation
494quax966 quantize   9.999E-15    1e-16 ->  1.00E-14  Inexact Rounded
495quax967 quantize   9.999E-15    1e-15 ->  1.0E-14   Inexact Rounded
496quax968 quantize   9.999E-15    1e-14 ->  1E-14     Inexact Rounded
497quax969 quantize   9.999E-15    1e-13 ->  0E-13     Inexact Rounded
498quax970 quantize   9.999E-15    1e-12 ->  0E-12     Inexact Rounded
499quax971 quantize   9.999E-15    1e-11 ->  0E-11     Inexact Rounded
500quax972 quantize   9.999E-15    1e-10 ->  0E-10     Inexact Rounded
501quax973 quantize   9.999E-15     1e-9 ->  0E-9      Inexact Rounded
502quax974 quantize   9.999E-15     1e-8 ->  0E-8      Inexact Rounded
503quax975 quantize   9.999E-15     1e-7 ->  0E-7      Inexact Rounded
504quax976 quantize   9.999E-15     1e-6 ->  0.000000  Inexact Rounded
505quax977 quantize   9.999E-15     1e-5 ->  0.00000   Inexact Rounded
506quax978 quantize   9.999E-15     1e-4 ->  0.0000    Inexact Rounded
507quax979 quantize   9.999E-15     1e-3 ->  0.000     Inexact Rounded
508quax980 quantize   9.999E-15     1e-2 ->  0.00      Inexact Rounded
509quax981 quantize   9.999E-15     1e-1 ->  0.0       Inexact Rounded
510quax982 quantize   9.999E-15      1e0 ->  0         Inexact Rounded
511quax983 quantize   9.999E-15      1e1 ->  0E+1      Inexact Rounded
512
513-- Fung Lee's case & similar
514precision: 3
515quax1001 quantize  0.000        0.001 ->  0.000
516quax1002 quantize  0.001        0.001 ->  0.001
517quax1003 quantize  0.0012       0.001 ->  0.001     Inexact Rounded
518quax1004 quantize  0.0018       0.001 ->  0.002     Inexact Rounded
519quax1005 quantize  0.501        0.001 ->  0.501
520quax1006 quantize  0.5012       0.001 ->  0.501     Inexact Rounded
521quax1007 quantize  0.5018       0.001 ->  0.502     Inexact Rounded
522quax1008 quantize  0.999        0.001 ->  0.999
523quax1009 quantize  0.9992       0.001 ->  0.999     Inexact Rounded
524quax1010 quantize  0.9998       0.001 ->  NaN       Invalid_operation
525quax1011 quantize  1.0001       0.001 ->  NaN       Invalid_operation
526quax1012 quantize  1.0051       0.001 ->  NaN       Invalid_operation
527quax1013 quantize  1.0551       0.001 ->  NaN       Invalid_operation
528quax1014 quantize  1.5551       0.001 ->  NaN       Invalid_operation
529quax1015 quantize  1.9999       0.001 ->  NaN       Invalid_operation
530
531-- long operand checks [rhs checks removed]
532maxexponent: 999
533minexponent: -999
534precision: 9
535quax481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
536quax482 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
537quax483 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
538quax484 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
539quax485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
540quax486 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
541-- a potential double-round
542quax487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
543quax488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
544
545precision: 15
546quax491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
547quax492 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
548quax493 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
549quax494 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
550quax495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
551quax496 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
552quax497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
553quax498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
554
555-- Zeros
556quax500 quantize   0     1e1 ->  0E+1
557quax501 quantize   0     1e0 ->  0
558quax502 quantize   0    1e-1 ->  0.0
559quax503 quantize   0.0  1e-1 ->  0.0
560quax504 quantize   0.0   1e0 ->  0
561quax505 quantize   0.0  1e+1 ->  0E+1
562quax506 quantize   0E+1 1e-1 ->  0.0
563quax507 quantize   0E+1  1e0 ->  0
564quax508 quantize   0E+1 1e+1 ->  0E+1
565quax509 quantize  -0     1e1 -> -0E+1
566quax510 quantize  -0     1e0 -> -0
567quax511 quantize  -0    1e-1 -> -0.0
568quax512 quantize  -0.0  1e-1 -> -0.0
569quax513 quantize  -0.0   1e0 -> -0
570quax514 quantize  -0.0  1e+1 -> -0E+1
571quax515 quantize  -0E+1 1e-1 -> -0.0
572quax516 quantize  -0E+1  1e0 -> -0
573quax517 quantize  -0E+1 1e+1 -> -0E+1
574
575-- Suspicious RHS values
576maxexponent: 999999999
577minexponent: -999999999
578precision: 15
579quax520 quantize   1.234    1e999999000 -> 0E+999999000 Inexact Rounded
580quax521 quantize 123.456    1e999999000 -> 0E+999999000 Inexact Rounded
581quax522 quantize   1.234    1e999999999 -> 0E+999999999 Inexact Rounded
582quax523 quantize 123.456    1e999999999 -> 0E+999999999 Inexact Rounded
583quax524 quantize 123.456   1e1000000000 -> NaN Invalid_operation
584quax525 quantize 123.456  1e12345678903 -> NaN Invalid_operation
585-- next four are "won't fit" overflows
586quax526 quantize   1.234   1e-999999000 -> NaN Invalid_operation
587quax527 quantize 123.456   1e-999999000 -> NaN Invalid_operation
588quax528 quantize   1.234   1e-999999999 -> NaN Invalid_operation
589quax529 quantize 123.456   1e-999999999 -> NaN Invalid_operation
590quax530 quantize 123.456  1e-1000000014 -> NaN Invalid_operation
591quax531 quantize 123.456 1e-12345678903 -> NaN Invalid_operation
592
593maxexponent: 999
594minexponent: -999
595precision: 15
596quax532 quantize   1.234E+999    1e999 -> 1E+999    Inexact Rounded
597quax533 quantize   1.234E+998    1e999 -> 0E+999    Inexact Rounded
598quax534 quantize   1.234         1e999 -> 0E+999    Inexact Rounded
599quax535 quantize   1.234        1e1000 -> NaN Invalid_operation
600quax536 quantize   1.234        1e5000 -> NaN Invalid_operation
601quax537 quantize   0            1e-999 -> 0E-999
602-- next two are "won't fit" overflows
603quax538 quantize   1.234        1e-999 -> NaN Invalid_operation
604quax539 quantize   1.234       1e-1000 -> NaN Invalid_operation
605quax540 quantize   1.234       1e-5000 -> NaN Invalid_operation
606-- [more below]
607
608-- check bounds (lhs maybe out of range for destination, etc.)
609precision:     7
610quax541 quantize   1E+999   1e+999 -> 1E+999
611quax542 quantize   1E+1000  1e+999 -> NaN Invalid_operation
612quax543 quantize   1E+999  1e+1000 -> NaN Invalid_operation
613quax544 quantize   1E-999   1e-999 -> 1E-999
614quax545 quantize   1E-1000  1e-999 -> 0E-999    Inexact Rounded
615quax546 quantize   1E-999  1e-1000 -> 1.0E-999
616quax547 quantize   1E-1005  1e-999 -> 0E-999    Inexact Rounded
617quax548 quantize   1E-1006  1e-999 -> 0E-999    Inexact Rounded
618quax549 quantize   1E-1007  1e-999 -> 0E-999    Inexact Rounded
619quax550 quantize   1E-998  1e-1005 -> NaN Invalid_operation  -- won't fit
620quax551 quantize   1E-999  1e-1005 -> 1.000000E-999
621quax552 quantize   1E-1000 1e-1005 -> 1.00000E-1000 Subnormal
622quax553 quantize   1E-999  1e-1006 -> NaN Invalid_operation
623quax554 quantize   1E-999  1e-1007 -> NaN Invalid_operation
624-- related subnormal rounding
625quax555 quantize   1.666666E-999  1e-1005 -> 1.666666E-999
626quax556 quantize   1.666666E-1000 1e-1005 -> 1.66667E-1000  Subnormal Inexact Rounded
627quax557 quantize   1.666666E-1001 1e-1005 -> 1.6667E-1001  Subnormal Inexact Rounded
628quax558 quantize   1.666666E-1002 1e-1005 -> 1.667E-1002  Subnormal Inexact Rounded
629quax559 quantize   1.666666E-1003 1e-1005 -> 1.67E-1003  Subnormal Inexact Rounded
630quax560 quantize   1.666666E-1004 1e-1005 -> 1.7E-1004  Subnormal Inexact Rounded
631quax561 quantize   1.666666E-1005 1e-1005 -> 2E-1005  Subnormal Inexact Rounded
632quax562 quantize   1.666666E-1006 1e-1005 -> 0E-1005   Inexact Rounded
633quax563 quantize   1.666666E-1007 1e-1005 -> 0E-1005   Inexact Rounded
634
635-- Specials
636quax580 quantize  Inf    -Inf   ->  Infinity
637quax581 quantize  Inf  1e-1000  ->  NaN  Invalid_operation
638quax582 quantize  Inf  1e-1     ->  NaN  Invalid_operation
639quax583 quantize  Inf   1e0     ->  NaN  Invalid_operation
640quax584 quantize  Inf   1e1     ->  NaN  Invalid_operation
641quax585 quantize  Inf   1e1000  ->  NaN  Invalid_operation
642quax586 quantize  Inf     Inf   ->  Infinity
643quax587 quantize -1000    Inf   ->  NaN  Invalid_operation
644quax588 quantize -Inf     Inf   ->  -Infinity
645quax589 quantize -1       Inf   ->  NaN  Invalid_operation
646quax590 quantize  0       Inf   ->  NaN  Invalid_operation
647quax591 quantize  1       Inf   ->  NaN  Invalid_operation
648quax592 quantize  1000    Inf   ->  NaN  Invalid_operation
649quax593 quantize  Inf     Inf   ->  Infinity
650quax594 quantize  Inf  1e-0     ->  NaN  Invalid_operation
651quax595 quantize -0       Inf   ->  NaN  Invalid_operation
652
653quax600 quantize -Inf    -Inf   ->  -Infinity
654quax601 quantize -Inf  1e-1000  ->  NaN  Invalid_operation
655quax602 quantize -Inf  1e-1     ->  NaN  Invalid_operation
656quax603 quantize -Inf   1e0     ->  NaN  Invalid_operation
657quax604 quantize -Inf   1e1     ->  NaN  Invalid_operation
658quax605 quantize -Inf   1e1000  ->  NaN  Invalid_operation
659quax606 quantize -Inf     Inf   ->  -Infinity
660quax607 quantize -1000    Inf   ->  NaN  Invalid_operation
661quax608 quantize -Inf    -Inf   ->  -Infinity
662quax609 quantize -1      -Inf   ->  NaN  Invalid_operation
663quax610 quantize  0      -Inf   ->  NaN  Invalid_operation
664quax611 quantize  1      -Inf   ->  NaN  Invalid_operation
665quax612 quantize  1000   -Inf   ->  NaN  Invalid_operation
666quax613 quantize  Inf    -Inf   ->  Infinity
667quax614 quantize -Inf  1e-0     ->  NaN  Invalid_operation
668quax615 quantize -0      -Inf   ->  NaN  Invalid_operation
669
670quax621 quantize  NaN   -Inf    ->  NaN
671quax622 quantize  NaN 1e-1000   ->  NaN
672quax623 quantize  NaN 1e-1      ->  NaN
673quax624 quantize  NaN  1e0      ->  NaN
674quax625 quantize  NaN  1e1      ->  NaN
675quax626 quantize  NaN  1e1000   ->  NaN
676quax627 quantize  NaN    Inf    ->  NaN
677quax628 quantize  NaN    NaN    ->  NaN
678quax629 quantize -Inf    NaN    ->  NaN
679quax630 quantize -1000   NaN    ->  NaN
680quax631 quantize -1      NaN    ->  NaN
681quax632 quantize  0      NaN    ->  NaN
682quax633 quantize  1      NaN    ->  NaN
683quax634 quantize  1000   NaN    ->  NaN
684quax635 quantize  Inf    NaN    ->  NaN
685quax636 quantize  NaN 1e-0      ->  NaN
686quax637 quantize -0      NaN    ->  NaN
687
688quax641 quantize  sNaN   -Inf   ->  NaN  Invalid_operation
689quax642 quantize  sNaN 1e-1000  ->  NaN  Invalid_operation
690quax643 quantize  sNaN 1e-1     ->  NaN  Invalid_operation
691quax644 quantize  sNaN  1e0     ->  NaN  Invalid_operation
692quax645 quantize  sNaN  1e1     ->  NaN  Invalid_operation
693quax646 quantize  sNaN  1e1000  ->  NaN  Invalid_operation
694quax647 quantize  sNaN    NaN   ->  NaN  Invalid_operation
695quax648 quantize  sNaN   sNaN   ->  NaN  Invalid_operation
696quax649 quantize  NaN    sNaN   ->  NaN  Invalid_operation
697quax650 quantize -Inf    sNaN   ->  NaN  Invalid_operation
698quax651 quantize -1000   sNaN   ->  NaN  Invalid_operation
699quax652 quantize -1      sNaN   ->  NaN  Invalid_operation
700quax653 quantize  0      sNaN   ->  NaN  Invalid_operation
701quax654 quantize  1      sNaN   ->  NaN  Invalid_operation
702quax655 quantize  1000   sNaN   ->  NaN  Invalid_operation
703quax656 quantize  Inf    sNaN   ->  NaN  Invalid_operation
704quax657 quantize  NaN    sNaN   ->  NaN  Invalid_operation
705quax658 quantize  sNaN 1e-0     ->  NaN  Invalid_operation
706quax659 quantize -0      sNaN   ->  NaN  Invalid_operation
707
708-- propagating NaNs
709quax661 quantize  NaN9 -Inf   ->  NaN9
710quax662 quantize  NaN8  919   ->  NaN8
711quax663 quantize  NaN71 Inf   ->  NaN71
712quax664 quantize  NaN6  NaN5  ->  NaN6
713quax665 quantize -Inf   NaN4  ->  NaN4
714quax666 quantize -919   NaN31 ->  NaN31
715quax667 quantize  Inf   NaN2  ->  NaN2
716
717quax671 quantize  sNaN99 -Inf    ->  NaN99 Invalid_operation
718quax672 quantize  sNaN98 -11     ->  NaN98 Invalid_operation
719quax673 quantize  sNaN97  NaN    ->  NaN97 Invalid_operation
720quax674 quantize  sNaN16 sNaN94  ->  NaN16 Invalid_operation
721quax675 quantize  NaN95  sNaN93  ->  NaN93 Invalid_operation
722quax676 quantize -Inf    sNaN92  ->  NaN92 Invalid_operation
723quax677 quantize  088    sNaN91  ->  NaN91 Invalid_operation
724quax678 quantize  Inf    sNaN90  ->  NaN90 Invalid_operation
725quax679 quantize  NaN    sNaN88  ->  NaN88 Invalid_operation
726
727quax681 quantize -NaN9 -Inf   -> -NaN9
728quax682 quantize -NaN8  919   -> -NaN8
729quax683 quantize -NaN71 Inf   -> -NaN71
730quax684 quantize -NaN6 -NaN5  -> -NaN6
731quax685 quantize -Inf  -NaN4  -> -NaN4
732quax686 quantize -919  -NaN31 -> -NaN31
733quax687 quantize  Inf  -NaN2  -> -NaN2
734
735quax691 quantize -sNaN99 -Inf    -> -NaN99 Invalid_operation
736quax692 quantize -sNaN98 -11     -> -NaN98 Invalid_operation
737quax693 quantize -sNaN97  NaN    -> -NaN97 Invalid_operation
738quax694 quantize -sNaN16 sNaN94  -> -NaN16 Invalid_operation
739quax695 quantize -NaN95 -sNaN93  -> -NaN93 Invalid_operation
740quax696 quantize -Inf   -sNaN92  -> -NaN92 Invalid_operation
741quax697 quantize  088   -sNaN91  -> -NaN91 Invalid_operation
742quax698 quantize  Inf   -sNaN90  -> -NaN90 Invalid_operation
743quax699 quantize  NaN   -sNaN88  -> -NaN88 Invalid_operation
744
745-- subnormals and underflow
746precision: 4
747maxexponent: 999
748minexponent: -999
749quax710 quantize  1.00E-999    1e-999  ->   1E-999    Rounded
750quax711 quantize  0.1E-999    2e-1000  ->   1E-1000   Subnormal
751quax712 quantize  0.10E-999   3e-1000  ->   1E-1000   Subnormal Rounded
752quax713 quantize  0.100E-999  4e-1000  ->   1E-1000   Subnormal Rounded
753quax714 quantize  0.01E-999   5e-1001  ->   1E-1001   Subnormal
754-- next is rounded to Emin
755quax715 quantize  0.999E-999   1e-999  ->   1E-999    Inexact Rounded
756quax716 quantize  0.099E-999 10e-1000  ->   1E-1000   Inexact Rounded Subnormal
757
758quax717 quantize  0.009E-999  1e-1001  ->   1E-1001   Inexact Rounded Subnormal
759quax718 quantize  0.001E-999  1e-1001  ->   0E-1001   Inexact Rounded
760quax719 quantize  0.0009E-999 1e-1001  ->   0E-1001   Inexact Rounded
761quax720 quantize  0.0001E-999 1e-1001  ->   0E-1001   Inexact Rounded
762
763quax730 quantize -1.00E-999   1e-999  ->  -1E-999     Rounded
764quax731 quantize -0.1E-999    1e-999  ->  -0E-999     Rounded Inexact
765quax732 quantize -0.10E-999   1e-999  ->  -0E-999     Rounded Inexact
766quax733 quantize -0.100E-999  1e-999  ->  -0E-999     Rounded Inexact
767quax734 quantize -0.01E-999   1e-999  ->  -0E-999     Inexact Rounded
768-- next is rounded to Emin
769quax735 quantize -0.999E-999 90e-999  ->  -1E-999     Inexact Rounded
770quax736 quantize -0.099E-999 -1e-999  ->  -0E-999     Inexact Rounded
771quax737 quantize -0.009E-999 -1e-999  ->  -0E-999     Inexact Rounded
772quax738 quantize -0.001E-999 -0e-999  ->  -0E-999     Inexact Rounded
773quax739 quantize -0.0001E-999 0e-999  ->  -0E-999     Inexact Rounded
774
775quax740 quantize -1.00E-999   1e-1000 ->  -1.0E-999   Rounded
776quax741 quantize -0.1E-999    1e-1000 ->  -1E-1000    Subnormal
777quax742 quantize -0.10E-999   1e-1000 ->  -1E-1000    Subnormal Rounded
778quax743 quantize -0.100E-999  1e-1000 ->  -1E-1000    Subnormal Rounded
779quax744 quantize -0.01E-999   1e-1000 ->  -0E-1000    Inexact Rounded
780-- next is rounded to Emin
781quax745 quantize -0.999E-999  1e-1000 ->  -1.0E-999   Inexact Rounded
782quax746 quantize -0.099E-999  1e-1000 ->  -1E-1000    Inexact Rounded Subnormal
783quax747 quantize -0.009E-999  1e-1000 ->  -0E-1000    Inexact Rounded
784quax748 quantize -0.001E-999  1e-1000 ->  -0E-1000    Inexact Rounded
785quax749 quantize -0.0001E-999 1e-1000 ->  -0E-1000    Inexact Rounded
786
787quax750 quantize -1.00E-999   1e-1001 ->  -1.00E-999
788quax751 quantize -0.1E-999    1e-1001 ->  -1.0E-1000  Subnormal
789quax752 quantize -0.10E-999   1e-1001 ->  -1.0E-1000  Subnormal
790quax753 quantize -0.100E-999  1e-1001 ->  -1.0E-1000  Subnormal Rounded
791quax754 quantize -0.01E-999   1e-1001 ->  -1E-1001    Subnormal
792-- next is rounded to Emin
793quax755 quantize -0.999E-999  1e-1001 ->  -1.00E-999  Inexact Rounded
794quax756 quantize -0.099E-999  1e-1001 ->  -1.0E-1000  Inexact Rounded Subnormal
795quax757 quantize -0.009E-999  1e-1001 ->  -1E-1001    Inexact Rounded Subnormal
796quax758 quantize -0.001E-999  1e-1001 ->  -0E-1001    Inexact Rounded
797quax759 quantize -0.0001E-999 1e-1001 ->  -0E-1001    Inexact Rounded
798
799quax760 quantize -1.00E-999   1e-1002 ->  -1.000E-999
800quax761 quantize -0.1E-999    1e-1002 ->  -1.00E-1000  Subnormal
801quax762 quantize -0.10E-999   1e-1002 ->  -1.00E-1000  Subnormal
802quax763 quantize -0.100E-999  1e-1002 ->  -1.00E-1000  Subnormal
803quax764 quantize -0.01E-999   1e-1002 ->  -1.0E-1001   Subnormal
804quax765 quantize -0.999E-999  1e-1002 ->  -9.99E-1000  Subnormal
805quax766 quantize -0.099E-999  1e-1002 ->  -9.9E-1001   Subnormal
806quax767 quantize -0.009E-999  1e-1002 ->  -9E-1002     Subnormal
807quax768 quantize -0.001E-999  1e-1002 ->  -1E-1002     Subnormal
808quax769 quantize -0.0001E-999 1e-1002 ->  -0E-1002     Inexact Rounded
809
810-- rhs must be no less than Etiny
811quax770 quantize -1.00E-999   1e-1003 ->  NaN Invalid_operation
812quax771 quantize -0.1E-999    1e-1003 ->  NaN Invalid_operation
813quax772 quantize -0.10E-999   1e-1003 ->  NaN Invalid_operation
814quax773 quantize -0.100E-999  1e-1003 ->  NaN Invalid_operation
815quax774 quantize -0.01E-999   1e-1003 ->  NaN Invalid_operation
816quax775 quantize -0.999E-999  1e-1003 ->  NaN Invalid_operation
817quax776 quantize -0.099E-999  1e-1003 ->  NaN Invalid_operation
818quax777 quantize -0.009E-999  1e-1003 ->  NaN Invalid_operation
819quax778 quantize -0.001E-999  1e-1003 ->  NaN Invalid_operation
820quax779 quantize -0.0001E-999 1e-1003 ->  NaN Invalid_operation
821quax780 quantize -0.0001E-999 1e-1004 ->  NaN Invalid_operation
822
823precision:   9
824maxExponent: 999999999
825minexponent: -999999999
826
827-- some extremes derived from Rescale testcases
828quax801 quantize   0   1e1000000000 -> NaN Invalid_operation
829quax802 quantize   0  1e-1000000000 -> 0E-1000000000
830quax803 quantize   0   1e2000000000 -> NaN Invalid_operation
831quax804 quantize   0  1e-2000000000 -> NaN Invalid_operation
832quax805 quantize   0   1e3000000000 -> NaN Invalid_operation
833quax806 quantize   0  1e-3000000000 -> NaN Invalid_operation
834quax807 quantize   0   1e4000000000 -> NaN Invalid_operation
835quax808 quantize   0  1e-4000000000 -> NaN Invalid_operation
836quax809 quantize   0   1e5000000000 -> NaN Invalid_operation
837quax810 quantize   0  1e-5000000000 -> NaN Invalid_operation
838quax811 quantize   0   1e6000000000 -> NaN Invalid_operation
839quax812 quantize   0  1e-6000000000 -> NaN Invalid_operation
840quax813 quantize   0   1e7000000000 -> NaN Invalid_operation
841quax814 quantize   0  1e-7000000000 -> NaN Invalid_operation
842quax815 quantize   0   1e8000000000 -> NaN Invalid_operation
843quax816 quantize   0  1e-8000000000 -> NaN Invalid_operation
844quax817 quantize   0   1e9000000000 -> NaN Invalid_operation
845quax818 quantize   0  1e-9000000000 -> NaN Invalid_operation
846quax819 quantize   0   1e9999999999 -> NaN Invalid_operation
847quax820 quantize   0  1e-9999999999 -> NaN Invalid_operation
848quax821 quantize   0   1e10000000000 -> NaN Invalid_operation
849quax822 quantize   0  1e-10000000000 -> NaN Invalid_operation
850
851quax843 quantize   0    1e999999999 -> 0E+999999999
852quax844 quantize   0   1e1000000000 -> NaN Invalid_operation
853quax845 quantize   0   1e-999999999 -> 0E-999999999
854quax846 quantize   0  1e-1000000000 -> 0E-1000000000
855quax847 quantize   0  1e-1000000001 -> 0E-1000000001
856quax848 quantize   0  1e-1000000002 -> 0E-1000000002
857quax849 quantize   0  1e-1000000003 -> 0E-1000000003
858quax850 quantize   0  1e-1000000004 -> 0E-1000000004
859quax851 quantize   0  1e-1000000005 -> 0E-1000000005
860quax852 quantize   0  1e-1000000006 -> 0E-1000000006
861quax853 quantize   0  1e-1000000007 -> 0E-1000000007
862quax854 quantize   0  1e-1000000008 -> NaN Invalid_operation
863
864quax861 quantize   1  1e+2147483649 -> NaN Invalid_operation
865quax862 quantize   1  1e+2147483648 -> NaN Invalid_operation
866quax863 quantize   1  1e+2147483647 -> NaN Invalid_operation
867quax864 quantize   1  1e-2147483647 -> NaN Invalid_operation
868quax865 quantize   1  1e-2147483648 -> NaN Invalid_operation
869quax866 quantize   1  1e-2147483649 -> NaN Invalid_operation
870
871-- More from Fung Lee
872precision:   16
873rounding:    half_up
874maxExponent: 384
875minExponent: -383
876quax1021 quantize    8.666666666666000E+384     1.000000000000000E+384  -> 8.666666666666000E+384
877quax1022 quantize 64#8.666666666666000E+384  64#1.000000000000000E+384  -> 8.666666666666000E+384
878quax1023 quantize 64#8.666666666666000E+384  128#1.000000000000000E+384 -> 8.666666666666000E+384
879quax1024 quantize 64#8.666666666666000E+384  64#1E+384                  -> 8.666666666666000E+384
880quax1025 quantize 64#8.666666666666000E+384  64#1E+384   -> 64#8.666666666666000E+384
881quax1026 quantize 64#8.666666666666000E+384 128#1E+384   -> 64#9E+384 Inexact Rounded Clamped
882quax1027 quantize 64#8.666666666666000E+323  64#1E+31    -> NaN Invalid_operation
883quax1028 quantize 64#8.666666666666000E+323 128#1E+31    -> NaN Invalid_operation
884quax1029 quantize 64#8.66666666E+3          128#1E+10    -> 64#0E10 Inexact Rounded
885quax1030 quantize    8.66666666E+3              1E+3     -> 9E+3 Inexact Rounded
886
887-- Int and uInt32 edge values for testing conversions
888quax1040 quantize -2147483646     0 -> -2147483646
889quax1041 quantize -2147483647     0 -> -2147483647
890quax1042 quantize -2147483648     0 -> -2147483648
891quax1043 quantize -2147483649     0 -> -2147483649
892quax1044 quantize  2147483646     0 ->  2147483646
893quax1045 quantize  2147483647     0 ->  2147483647
894quax1046 quantize  2147483648     0 ->  2147483648
895quax1047 quantize  2147483649     0 ->  2147483649
896quax1048 quantize  4294967294     0 ->  4294967294
897quax1049 quantize  4294967295     0 ->  4294967295
898quax1050 quantize  4294967296     0 ->  4294967296
899quax1051 quantize  4294967297     0 ->  4294967297
900-- and powers of ten for same
901quax1101 quantize  5000000000     0 ->  5000000000
902quax1102 quantize  4000000000     0 ->  4000000000
903quax1103 quantize  2000000000     0 ->  2000000000
904quax1104 quantize  1000000000     0 ->  1000000000
905quax1105 quantize  0100000000     0 ->  100000000
906quax1106 quantize  0010000000     0 ->  10000000
907quax1107 quantize  0001000000     0 ->  1000000
908quax1108 quantize  0000100000     0 ->  100000
909quax1109 quantize  0000010000     0 ->  10000
910quax1110 quantize  0000001000     0 ->  1000
911quax1111 quantize  0000000100     0 ->  100
912quax1112 quantize  0000000010     0 ->  10
913quax1113 quantize  0000000001     0 ->  1
914quax1114 quantize  0000000000     0 ->  0
915-- and powers of ten for same
916quax1121 quantize -5000000000     0 -> -5000000000
917quax1122 quantize -4000000000     0 -> -4000000000
918quax1123 quantize -2000000000     0 -> -2000000000
919quax1124 quantize -1000000000     0 -> -1000000000
920quax1125 quantize -0100000000     0 -> -100000000
921quax1126 quantize -0010000000     0 -> -10000000
922quax1127 quantize -0001000000     0 -> -1000000
923quax1128 quantize -0000100000     0 -> -100000
924quax1129 quantize -0000010000     0 -> -10000
925quax1130 quantize -0000001000     0 -> -1000
926quax1131 quantize -0000000100     0 -> -100
927quax1132 quantize -0000000010     0 -> -10
928quax1133 quantize -0000000001     0 -> -1
929quax1134 quantize -0000000000     0 -> -0
930
931-- Some miscellany
932precision:   34
933rounding:    half_up
934maxExponent: 6144
935minExponent: -6143
936--                             1         2         3
937--                   1 234567890123456789012345678901234
938quax0a1 quantize     8.555555555555555555555555555555555E+6143  1E+6143      -> 9E+6143   Inexact Rounded
939quax0a2 quantize 128#8.555555555555555555555555555555555E+6143  128#1E+6143  -> 8.55555555555555555555555555555556E+6143   Rounded Inexact
940quax0a3 quantize 128#8.555555555555555555555555555555555E+6144  128#1E+6144  -> 8.555555555555555555555555555555555E+6144
941
942-- payload decapitate
943precision: 5
944quax62100 quantize 11 -sNaN1234567890 -> -NaN67890  Invalid_operation
945
946-- Null tests
947quax998 quantize 10    # -> NaN Invalid_operation
948quax999 quantize  # 1e10 -> NaN Invalid_operation
949