1------------------------------------------------------------------------
2-- ddMaxMag.decTest -- decDouble maxnummag                            --
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-- we assume that base comparison is tested in compare.decTest, so
23-- these mainly cover special cases and rounding
24precision:   16
25maxExponent: 384
26minExponent: -383
27extended:    1
28clamp:       1
29rounding:    half_even
30
31-- sanity checks
32ddmxg001 maxmag  -2  -2  -> -2
33ddmxg002 maxmag  -2  -1  -> -2
34ddmxg003 maxmag  -2   0  -> -2
35ddmxg004 maxmag  -2   1  -> -2
36ddmxg005 maxmag  -2   2  ->  2
37ddmxg006 maxmag  -1  -2  -> -2
38ddmxg007 maxmag  -1  -1  -> -1
39ddmxg008 maxmag  -1   0  -> -1
40ddmxg009 maxmag  -1   1  ->  1
41ddmxg010 maxmag  -1   2  ->  2
42ddmxg011 maxmag   0  -2  -> -2
43ddmxg012 maxmag   0  -1  -> -1
44ddmxg013 maxmag   0   0  ->  0
45ddmxg014 maxmag   0   1  ->  1
46ddmxg015 maxmag   0   2  ->  2
47ddmxg016 maxmag   1  -2  -> -2
48ddmxg017 maxmag   1  -1  ->  1
49ddmxg018 maxmag   1   0  ->  1
50ddmxg019 maxmag   1   1  ->  1
51ddmxg020 maxmag   1   2  ->  2
52ddmxg021 maxmag   2  -2  ->  2
53ddmxg022 maxmag   2  -1  ->  2
54ddmxg023 maxmag   2   0  ->  2
55ddmxg025 maxmag   2   1  ->  2
56ddmxg026 maxmag   2   2  ->  2
57
58-- extended zeros
59ddmxg030 maxmag   0     0   ->  0
60ddmxg031 maxmag   0    -0   ->  0
61ddmxg032 maxmag   0    -0.0 ->  0
62ddmxg033 maxmag   0     0.0 ->  0
63ddmxg034 maxmag  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
64ddmxg035 maxmag  -0    -0   -> -0
65ddmxg036 maxmag  -0    -0.0 -> -0.0
66ddmxg037 maxmag  -0     0.0 ->  0.0
67ddmxg038 maxmag   0.0   0   ->  0
68ddmxg039 maxmag   0.0  -0   ->  0.0
69ddmxg040 maxmag   0.0  -0.0 ->  0.0
70ddmxg041 maxmag   0.0   0.0 ->  0.0
71ddmxg042 maxmag  -0.0   0   ->  0
72ddmxg043 maxmag  -0.0  -0   -> -0.0
73ddmxg044 maxmag  -0.0  -0.0 -> -0.0
74ddmxg045 maxmag  -0.0   0.0 ->  0.0
75
76ddmxg050 maxmag  -0E1   0E1 ->  0E+1
77ddmxg051 maxmag  -0E2   0E2 ->  0E+2
78ddmxg052 maxmag  -0E2   0E1 ->  0E+1
79ddmxg053 maxmag  -0E1   0E2 ->  0E+2
80ddmxg054 maxmag   0E1  -0E1 ->  0E+1
81ddmxg055 maxmag   0E2  -0E2 ->  0E+2
82ddmxg056 maxmag   0E2  -0E1 ->  0E+2
83ddmxg057 maxmag   0E1  -0E2 ->  0E+1
84
85ddmxg058 maxmag   0E1   0E1 ->  0E+1
86ddmxg059 maxmag   0E2   0E2 ->  0E+2
87ddmxg060 maxmag   0E2   0E1 ->  0E+2
88ddmxg061 maxmag   0E1   0E2 ->  0E+2
89ddmxg062 maxmag  -0E1  -0E1 -> -0E+1
90ddmxg063 maxmag  -0E2  -0E2 -> -0E+2
91ddmxg064 maxmag  -0E2  -0E1 -> -0E+1
92ddmxg065 maxmag  -0E1  -0E2 -> -0E+1
93
94-- Specials
95ddmxg090 maxmag  Inf  -Inf   ->  Infinity
96ddmxg091 maxmag  Inf  -1000  ->  Infinity
97ddmxg092 maxmag  Inf  -1     ->  Infinity
98ddmxg093 maxmag  Inf  -0     ->  Infinity
99ddmxg094 maxmag  Inf   0     ->  Infinity
100ddmxg095 maxmag  Inf   1     ->  Infinity
101ddmxg096 maxmag  Inf   1000  ->  Infinity
102ddmxg097 maxmag  Inf   Inf   ->  Infinity
103ddmxg098 maxmag -1000  Inf   ->  Infinity
104ddmxg099 maxmag -Inf   Inf   ->  Infinity
105ddmxg100 maxmag -1     Inf   ->  Infinity
106ddmxg101 maxmag -0     Inf   ->  Infinity
107ddmxg102 maxmag  0     Inf   ->  Infinity
108ddmxg103 maxmag  1     Inf   ->  Infinity
109ddmxg104 maxmag  1000  Inf   ->  Infinity
110ddmxg105 maxmag  Inf   Inf   ->  Infinity
111
112ddmxg120 maxmag -Inf  -Inf   -> -Infinity
113ddmxg121 maxmag -Inf  -1000  -> -Infinity
114ddmxg122 maxmag -Inf  -1     -> -Infinity
115ddmxg123 maxmag -Inf  -0     -> -Infinity
116ddmxg124 maxmag -Inf   0     -> -Infinity
117ddmxg125 maxmag -Inf   1     -> -Infinity
118ddmxg126 maxmag -Inf   1000  -> -Infinity
119ddmxg127 maxmag -Inf   Inf   ->  Infinity
120ddmxg128 maxmag -Inf  -Inf   ->  -Infinity
121ddmxg129 maxmag -1000 -Inf   -> -Infinity
122ddmxg130 maxmag -1    -Inf   -> -Infinity
123ddmxg131 maxmag -0    -Inf   -> -Infinity
124ddmxg132 maxmag  0    -Inf   -> -Infinity
125ddmxg133 maxmag  1    -Inf   -> -Infinity
126ddmxg134 maxmag  1000 -Inf   -> -Infinity
127ddmxg135 maxmag  Inf  -Inf   ->  Infinity
128
129-- 2004.08.02 754r chooses number over NaN in mixed cases
130ddmxg141 maxmag  NaN -Inf    -> -Infinity
131ddmxg142 maxmag  NaN -1000   -> -1000
132ddmxg143 maxmag  NaN -1      -> -1
133ddmxg144 maxmag  NaN -0      -> -0
134ddmxg145 maxmag  NaN  0      ->  0
135ddmxg146 maxmag  NaN  1      ->  1
136ddmxg147 maxmag  NaN  1000   ->  1000
137ddmxg148 maxmag  NaN  Inf    ->  Infinity
138ddmxg149 maxmag  NaN  NaN    ->  NaN
139ddmxg150 maxmag -Inf  NaN    -> -Infinity
140ddmxg151 maxmag -1000 NaN    -> -1000
141ddmxg152 maxmag -1    NaN    -> -1
142ddmxg153 maxmag -0    NaN    -> -0
143ddmxg154 maxmag  0    NaN    ->  0
144ddmxg155 maxmag  1    NaN    ->  1
145ddmxg156 maxmag  1000 NaN    ->  1000
146ddmxg157 maxmag  Inf  NaN    ->  Infinity
147
148ddmxg161 maxmag  sNaN -Inf   ->  NaN  Invalid_operation
149ddmxg162 maxmag  sNaN -1000  ->  NaN  Invalid_operation
150ddmxg163 maxmag  sNaN -1     ->  NaN  Invalid_operation
151ddmxg164 maxmag  sNaN -0     ->  NaN  Invalid_operation
152ddmxg165 maxmag  sNaN  0     ->  NaN  Invalid_operation
153ddmxg166 maxmag  sNaN  1     ->  NaN  Invalid_operation
154ddmxg167 maxmag  sNaN  1000  ->  NaN  Invalid_operation
155ddmxg168 maxmag  sNaN  NaN   ->  NaN  Invalid_operation
156ddmxg169 maxmag  sNaN sNaN   ->  NaN  Invalid_operation
157ddmxg170 maxmag  NaN  sNaN   ->  NaN  Invalid_operation
158ddmxg171 maxmag -Inf  sNaN   ->  NaN  Invalid_operation
159ddmxg172 maxmag -1000 sNaN   ->  NaN  Invalid_operation
160ddmxg173 maxmag -1    sNaN   ->  NaN  Invalid_operation
161ddmxg174 maxmag -0    sNaN   ->  NaN  Invalid_operation
162ddmxg175 maxmag  0    sNaN   ->  NaN  Invalid_operation
163ddmxg176 maxmag  1    sNaN   ->  NaN  Invalid_operation
164ddmxg177 maxmag  1000 sNaN   ->  NaN  Invalid_operation
165ddmxg178 maxmag  Inf  sNaN   ->  NaN  Invalid_operation
166ddmxg179 maxmag  NaN  sNaN   ->  NaN  Invalid_operation
167
168-- propagating NaNs
169ddmxg181 maxmag  NaN9  -Inf   -> -Infinity
170ddmxg182 maxmag  NaN8     9   ->  9
171ddmxg183 maxmag -NaN7   Inf   ->  Infinity
172
173ddmxg184 maxmag -NaN1   NaN11 -> -NaN1
174ddmxg185 maxmag  NaN2   NaN12 ->  NaN2
175ddmxg186 maxmag -NaN13 -NaN7  -> -NaN13
176ddmxg187 maxmag  NaN14 -NaN5  ->  NaN14
177
178ddmxg188 maxmag -Inf    NaN4  -> -Infinity
179ddmxg189 maxmag -9     -NaN3  -> -9
180ddmxg190 maxmag  Inf    NaN2  ->  Infinity
181
182ddmxg191 maxmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
183ddmxg192 maxmag  sNaN98 -1      ->  NaN98 Invalid_operation
184ddmxg193 maxmag -sNaN97  NaN    -> -NaN97 Invalid_operation
185ddmxg194 maxmag  sNaN96 sNaN94  ->  NaN96 Invalid_operation
186ddmxg195 maxmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
187ddmxg196 maxmag -Inf    sNaN92  ->  NaN92 Invalid_operation
188ddmxg197 maxmag  0      sNaN91  ->  NaN91 Invalid_operation
189ddmxg198 maxmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
190ddmxg199 maxmag  NaN    sNaN89  ->  NaN89 Invalid_operation
191
192-- old rounding checks
193ddmxg221 maxmag 12345678000 1  -> 12345678000
194ddmxg222 maxmag 1 12345678000  -> 12345678000
195ddmxg223 maxmag 1234567800  1  -> 1234567800
196ddmxg224 maxmag 1 1234567800   -> 1234567800
197ddmxg225 maxmag 1234567890  1  -> 1234567890
198ddmxg226 maxmag 1 1234567890   -> 1234567890
199ddmxg227 maxmag 1234567891  1  -> 1234567891
200ddmxg228 maxmag 1 1234567891   -> 1234567891
201ddmxg229 maxmag 12345678901 1  -> 12345678901
202ddmxg230 maxmag 1 12345678901  -> 12345678901
203ddmxg231 maxmag 1234567896  1  -> 1234567896
204ddmxg232 maxmag 1 1234567896   -> 1234567896
205ddmxg233 maxmag -1234567891  1 -> -1234567891
206ddmxg234 maxmag 1 -1234567891  -> -1234567891
207ddmxg235 maxmag -12345678901 1 -> -12345678901
208ddmxg236 maxmag 1 -12345678901 -> -12345678901
209ddmxg237 maxmag -1234567896  1 -> -1234567896
210ddmxg238 maxmag 1 -1234567896  -> -1234567896
211
212-- from examples
213ddmxg280 maxmag '3'   '2'  ->  '3'
214ddmxg281 maxmag '-10' '3'  ->  '-10'
215ddmxg282 maxmag '1.0' '1'  ->  '1'
216ddmxg283 maxmag '1' '1.0'  ->  '1'
217ddmxg284 maxmag '7' 'NaN'  ->  '7'
218
219-- expanded list from min/max 754r purple prose
220-- [explicit tests for exponent ordering]
221ddmxg401 maxmag  Inf    1.1     ->  Infinity
222ddmxg402 maxmag  1.1    1       ->  1.1
223ddmxg403 maxmag  1      1.0     ->  1
224ddmxg404 maxmag  1.0    0.1     ->  1.0
225ddmxg405 maxmag  0.1    0.10    ->  0.1
226ddmxg406 maxmag  0.10   0.100   ->  0.10
227ddmxg407 maxmag  0.10   0       ->  0.10
228ddmxg408 maxmag  0      0.0     ->  0
229ddmxg409 maxmag  0.0   -0       ->  0.0
230ddmxg410 maxmag  0.0   -0.0     ->  0.0
231ddmxg411 maxmag  0.00  -0.0     ->  0.00
232ddmxg412 maxmag  0.0   -0.00    ->  0.0
233ddmxg413 maxmag  0     -0.0     ->  0
234ddmxg414 maxmag  0     -0       ->  0
235ddmxg415 maxmag -0.0   -0       -> -0.0
236ddmxg416 maxmag -0     -0.100   -> -0.100
237ddmxg417 maxmag -0.100 -0.10    -> -0.100
238ddmxg418 maxmag -0.10  -0.1     -> -0.10
239ddmxg419 maxmag -0.1   -1.0     -> -1.0
240ddmxg420 maxmag -1.0   -1       -> -1.0
241ddmxg421 maxmag -1     -1.1     -> -1.1
242ddmxg423 maxmag -1.1   -Inf     -> -Infinity
243-- same with operands reversed
244ddmxg431 maxmag  1.1    Inf     ->  Infinity
245ddmxg432 maxmag  1      1.1     ->  1.1
246ddmxg433 maxmag  1.0    1       ->  1
247ddmxg434 maxmag  0.1    1.0     ->  1.0
248ddmxg435 maxmag  0.10   0.1     ->  0.1
249ddmxg436 maxmag  0.100  0.10    ->  0.10
250ddmxg437 maxmag  0      0.10    ->  0.10
251ddmxg438 maxmag  0.0    0       ->  0
252ddmxg439 maxmag -0      0.0     ->  0.0
253ddmxg440 maxmag -0.0    0.0     ->  0.0
254ddmxg441 maxmag -0.0    0.00    ->  0.00
255ddmxg442 maxmag -0.00   0.0     ->  0.0
256ddmxg443 maxmag -0.0    0       ->  0
257ddmxg444 maxmag -0      0       ->  0
258ddmxg445 maxmag -0     -0.0     -> -0.0
259ddmxg446 maxmag -0.100 -0       -> -0.100
260ddmxg447 maxmag -0.10  -0.100   -> -0.100
261ddmxg448 maxmag -0.1   -0.10    -> -0.10
262ddmxg449 maxmag -1.0   -0.1     -> -1.0
263ddmxg450 maxmag -1     -1.0     -> -1.0
264ddmxg451 maxmag -1.1   -1       -> -1.1
265ddmxg453 maxmag -Inf   -1.1     -> -Infinity
266-- largies
267ddmxg460 maxmag  1000   1E+3    ->  1E+3
268ddmxg461 maxmag  1E+3   1000    ->  1E+3
269ddmxg462 maxmag  1000  -1E+3    ->  1000
270ddmxg463 maxmag  1E+3  -1000    ->  1E+3
271ddmxg464 maxmag -1000   1E+3    ->  1E+3
272ddmxg465 maxmag -1E+3   1000    ->  1000
273ddmxg466 maxmag -1000  -1E+3    -> -1000
274ddmxg467 maxmag -1E+3  -1000    -> -1000
275
276-- subnormals
277ddmxg510 maxmag  1.00E-383       0  ->   1.00E-383
278ddmxg511 maxmag  0.1E-383        0  ->   1E-384    Subnormal
279ddmxg512 maxmag  0.10E-383       0  ->   1.0E-384  Subnormal
280ddmxg513 maxmag  0.100E-383      0  ->   1.00E-384 Subnormal
281ddmxg514 maxmag  0.01E-383       0  ->   1E-385    Subnormal
282ddmxg515 maxmag  0.999E-383      0  ->   9.99E-384 Subnormal
283ddmxg516 maxmag  0.099E-383      0  ->   9.9E-385  Subnormal
284ddmxg517 maxmag  0.009E-383      0  ->   9E-386    Subnormal
285ddmxg518 maxmag  0.001E-383      0  ->   1E-386    Subnormal
286ddmxg519 maxmag  0.0009E-383     0  ->   9E-387    Subnormal
287ddmxg520 maxmag  0.0001E-383     0  ->   1E-387    Subnormal
288
289ddmxg530 maxmag -1.00E-383       0  ->  -1.00E-383
290ddmxg531 maxmag -0.1E-383        0  ->  -1E-384    Subnormal
291ddmxg532 maxmag -0.10E-383       0  ->  -1.0E-384  Subnormal
292ddmxg533 maxmag -0.100E-383      0  ->  -1.00E-384 Subnormal
293ddmxg534 maxmag -0.01E-383       0  ->  -1E-385    Subnormal
294ddmxg535 maxmag -0.999E-383      0  ->  -9.99E-384 Subnormal
295ddmxg536 maxmag -0.099E-383      0  ->  -9.9E-385  Subnormal
296ddmxg537 maxmag -0.009E-383      0  ->  -9E-386    Subnormal
297ddmxg538 maxmag -0.001E-383      0  ->  -1E-386    Subnormal
298ddmxg539 maxmag -0.0009E-383     0  ->  -9E-387    Subnormal
299ddmxg540 maxmag -0.0001E-383     0  ->  -1E-387    Subnormal
300
301-- Null tests
302ddmxg900 maxmag 10  #  -> NaN Invalid_operation
303ddmxg901 maxmag  # 10  -> NaN Invalid_operation
304
305