• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1------------------------------------------------------------------------
2-- max.decTest -- decimal maximum                                     --
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
24
25extended:    1
26precision:   9
27rounding:    half_up
28maxExponent: 384
29minexponent: -383
30
31-- sanity checks
32maxx001 max  -2  -2  -> -2
33maxx002 max  -2  -1  -> -1
34maxx003 max  -2   0  ->  0
35maxx004 max  -2   1  ->  1
36maxx005 max  -2   2  ->  2
37maxx006 max  -1  -2  -> -1
38maxx007 max  -1  -1  -> -1
39maxx008 max  -1   0  ->  0
40maxx009 max  -1   1  ->  1
41maxx010 max  -1   2  ->  2
42maxx011 max   0  -2  ->  0
43maxx012 max   0  -1  ->  0
44maxx013 max   0   0  ->  0
45maxx014 max   0   1  ->  1
46maxx015 max   0   2  ->  2
47maxx016 max   1  -2  ->  1
48maxx017 max   1  -1  ->  1
49maxx018 max   1   0  ->  1
50maxx019 max   1   1  ->  1
51maxx020 max   1   2  ->  2
52maxx021 max   2  -2  ->  2
53maxx022 max   2  -1  ->  2
54maxx023 max   2   0  ->  2
55maxx025 max   2   1  ->  2
56maxx026 max   2   2  ->  2
57
58-- extended zeros
59maxx030 max   0     0   ->  0
60maxx031 max   0    -0   ->  0
61maxx032 max   0    -0.0 ->  0
62maxx033 max   0     0.0 ->  0
63maxx034 max  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
64maxx035 max  -0    -0   -> -0
65maxx036 max  -0    -0.0 -> -0.0
66maxx037 max  -0     0.0 ->  0.0
67maxx038 max   0.0   0   ->  0
68maxx039 max   0.0  -0   ->  0.0
69maxx040 max   0.0  -0.0 ->  0.0
70maxx041 max   0.0   0.0 ->  0.0
71maxx042 max  -0.0   0   ->  0
72maxx043 max  -0.0  -0   -> -0.0
73maxx044 max  -0.0  -0.0 -> -0.0
74maxx045 max  -0.0   0.0 ->  0.0
75
76maxx050 max  -0E1   0E1 ->  0E+1
77maxx051 max  -0E2   0E2 ->  0E+2
78maxx052 max  -0E2   0E1 ->  0E+1
79maxx053 max  -0E1   0E2 ->  0E+2
80maxx054 max   0E1  -0E1 ->  0E+1
81maxx055 max   0E2  -0E2 ->  0E+2
82maxx056 max   0E2  -0E1 ->  0E+2
83maxx057 max   0E1  -0E2 ->  0E+1
84
85maxx058 max   0E1   0E1 ->  0E+1
86maxx059 max   0E2   0E2 ->  0E+2
87maxx060 max   0E2   0E1 ->  0E+2
88maxx061 max   0E1   0E2 ->  0E+2
89maxx062 max  -0E1  -0E1 -> -0E+1
90maxx063 max  -0E2  -0E2 -> -0E+2
91maxx064 max  -0E2  -0E1 -> -0E+1
92maxx065 max  -0E1  -0E2 -> -0E+1
93
94-- Specials
95precision: 9
96maxx090 max  Inf  -Inf   ->  Infinity
97maxx091 max  Inf  -1000  ->  Infinity
98maxx092 max  Inf  -1     ->  Infinity
99maxx093 max  Inf  -0     ->  Infinity
100maxx094 max  Inf   0     ->  Infinity
101maxx095 max  Inf   1     ->  Infinity
102maxx096 max  Inf   1000  ->  Infinity
103maxx097 max  Inf   Inf   ->  Infinity
104maxx098 max -1000  Inf   ->  Infinity
105maxx099 max -Inf   Inf   ->  Infinity
106maxx100 max -1     Inf   ->  Infinity
107maxx101 max -0     Inf   ->  Infinity
108maxx102 max  0     Inf   ->  Infinity
109maxx103 max  1     Inf   ->  Infinity
110maxx104 max  1000  Inf   ->  Infinity
111maxx105 max  Inf   Inf   ->  Infinity
112
113maxx120 max -Inf  -Inf   -> -Infinity
114maxx121 max -Inf  -1000  -> -1000
115maxx122 max -Inf  -1     -> -1
116maxx123 max -Inf  -0     -> -0
117maxx124 max -Inf   0     ->  0
118maxx125 max -Inf   1     ->  1
119maxx126 max -Inf   1000  ->  1000
120maxx127 max -Inf   Inf   ->  Infinity
121maxx128 max -Inf  -Inf   ->  -Infinity
122maxx129 max -1000 -Inf   ->  -1000
123maxx130 max -1    -Inf   ->  -1
124maxx131 max -0    -Inf   ->  -0
125maxx132 max  0    -Inf   ->  0
126maxx133 max  1    -Inf   ->  1
127maxx134 max  1000 -Inf   ->  1000
128maxx135 max  Inf  -Inf   ->  Infinity
129
130-- 2004.08.02 754r chooses number over NaN in mixed cases
131maxx141 max  NaN -Inf    -> -Infinity
132maxx142 max  NaN -1000   -> -1000
133maxx143 max  NaN -1      -> -1
134maxx144 max  NaN -0      -> -0
135maxx145 max  NaN  0      ->  0
136maxx146 max  NaN  1      ->  1
137maxx147 max  NaN  1000   ->  1000
138maxx148 max  NaN  Inf    ->  Infinity
139maxx149 max  NaN  NaN    ->  NaN
140maxx150 max -Inf  NaN    -> -Infinity
141maxx151 max -1000 NaN    -> -1000
142maxx152 max -1    NaN    -> -1
143maxx153 max -0    NaN    -> -0
144maxx154 max  0    NaN    ->  0
145maxx155 max  1    NaN    ->  1
146maxx156 max  1000 NaN    ->  1000
147maxx157 max  Inf  NaN    ->  Infinity
148
149maxx161 max  sNaN -Inf   ->  NaN  Invalid_operation
150maxx162 max  sNaN -1000  ->  NaN  Invalid_operation
151maxx163 max  sNaN -1     ->  NaN  Invalid_operation
152maxx164 max  sNaN -0     ->  NaN  Invalid_operation
153maxx165 max  sNaN  0     ->  NaN  Invalid_operation
154maxx166 max  sNaN  1     ->  NaN  Invalid_operation
155maxx167 max  sNaN  1000  ->  NaN  Invalid_operation
156maxx168 max  sNaN  NaN   ->  NaN  Invalid_operation
157maxx169 max  sNaN sNaN   ->  NaN  Invalid_operation
158maxx170 max  NaN  sNaN   ->  NaN  Invalid_operation
159maxx171 max -Inf  sNaN   ->  NaN  Invalid_operation
160maxx172 max -1000 sNaN   ->  NaN  Invalid_operation
161maxx173 max -1    sNaN   ->  NaN  Invalid_operation
162maxx174 max -0    sNaN   ->  NaN  Invalid_operation
163maxx175 max  0    sNaN   ->  NaN  Invalid_operation
164maxx176 max  1    sNaN   ->  NaN  Invalid_operation
165maxx177 max  1000 sNaN   ->  NaN  Invalid_operation
166maxx178 max  Inf  sNaN   ->  NaN  Invalid_operation
167maxx179 max  NaN  sNaN   ->  NaN  Invalid_operation
168
169-- propagating NaNs
170maxx181 max  NaN9  -Inf   -> -Infinity
171maxx182 max  NaN8     9   ->  9
172maxx183 max -NaN7   Inf   ->  Infinity
173
174maxx184 max -NaN1   NaN11 -> -NaN1
175maxx185 max  NaN2   NaN12 ->  NaN2
176maxx186 max -NaN13 -NaN7  -> -NaN13
177maxx187 max  NaN14 -NaN5  ->  NaN14
178
179maxx188 max -Inf    NaN4  -> -Infinity
180maxx189 max -9     -NaN3  -> -9
181maxx190 max  Inf    NaN2  ->  Infinity
182
183maxx191 max  sNaN99 -Inf    ->  NaN99 Invalid_operation
184maxx192 max  sNaN98 -1      ->  NaN98 Invalid_operation
185maxx193 max -sNaN97  NaN    -> -NaN97 Invalid_operation
186maxx194 max  sNaN96 sNaN94  ->  NaN96 Invalid_operation
187maxx195 max  NaN95  sNaN93  ->  NaN93 Invalid_operation
188maxx196 max -Inf    sNaN92  ->  NaN92 Invalid_operation
189maxx197 max  0      sNaN91  ->  NaN91 Invalid_operation
190maxx198 max  Inf   -sNaN90  -> -NaN90 Invalid_operation
191maxx199 max  NaN    sNaN89  ->  NaN89 Invalid_operation
192
193-- rounding checks
194maxexponent: 999
195minexponent: -999
196precision: 9
197maxx201 max 12345678000 1  -> 1.23456780E+10 Rounded
198maxx202 max 1 12345678000  -> 1.23456780E+10 Rounded
199maxx203 max 1234567800  1  -> 1.23456780E+9 Rounded
200maxx204 max 1 1234567800   -> 1.23456780E+9 Rounded
201maxx205 max 1234567890  1  -> 1.23456789E+9 Rounded
202maxx206 max 1 1234567890   -> 1.23456789E+9 Rounded
203maxx207 max 1234567891  1  -> 1.23456789E+9 Inexact Rounded
204maxx208 max 1 1234567891   -> 1.23456789E+9 Inexact Rounded
205maxx209 max 12345678901 1  -> 1.23456789E+10 Inexact Rounded
206maxx210 max 1 12345678901  -> 1.23456789E+10 Inexact Rounded
207maxx211 max 1234567896  1  -> 1.23456790E+9 Inexact Rounded
208maxx212 max 1 1234567896   -> 1.23456790E+9 Inexact Rounded
209maxx213 max -1234567891  1 -> 1
210maxx214 max 1 -1234567891  -> 1
211maxx215 max -12345678901 1 -> 1
212maxx216 max 1 -12345678901 -> 1
213maxx217 max -1234567896  1 -> 1
214maxx218 max 1 -1234567896  -> 1
215
216precision: 15
217maxx221 max 12345678000 1  -> 12345678000
218maxx222 max 1 12345678000  -> 12345678000
219maxx223 max 1234567800  1  -> 1234567800
220maxx224 max 1 1234567800   -> 1234567800
221maxx225 max 1234567890  1  -> 1234567890
222maxx226 max 1 1234567890   -> 1234567890
223maxx227 max 1234567891  1  -> 1234567891
224maxx228 max 1 1234567891   -> 1234567891
225maxx229 max 12345678901 1  -> 12345678901
226maxx230 max 1 12345678901  -> 12345678901
227maxx231 max 1234567896  1  -> 1234567896
228maxx232 max 1 1234567896   -> 1234567896
229maxx233 max -1234567891  1 -> 1
230maxx234 max 1 -1234567891  -> 1
231maxx235 max -12345678901 1 -> 1
232maxx236 max 1 -12345678901 -> 1
233maxx237 max -1234567896  1 -> 1
234maxx238 max 1 -1234567896  -> 1
235
236-- from examples
237maxx280 max '3'   '2'  ->  '3'
238maxx281 max '-10' '3'  ->  '3'
239maxx282 max '1.0' '1'  ->  '1'
240maxx283 max '1' '1.0'  ->  '1'
241maxx284 max '7' 'NaN'  ->  '7'
242
243-- overflow and underflow tests ...
244maxExponent: 999999999
245minexponent: -999999999
246maxx330 max +1.23456789012345E-0 9E+999999999 ->  9E+999999999
247maxx331 max 9E+999999999 +1.23456789012345E-0 ->  9E+999999999
248maxx332 max +0.100 9E-999999999               ->  0.100
249maxx333 max 9E-999999999 +0.100               ->  0.100
250maxx335 max -1.23456789012345E-0 9E+999999999 ->  9E+999999999
251maxx336 max 9E+999999999 -1.23456789012345E-0 ->  9E+999999999
252maxx337 max -0.100 9E-999999999               ->  9E-999999999
253maxx338 max 9E-999999999 -0.100               ->  9E-999999999
254
255maxx339 max 1e-599999999 1e-400000001   ->  1E-400000001
256maxx340 max 1e-599999999 1e-400000000   ->  1E-400000000
257maxx341 max 1e-600000000 1e-400000000   ->  1E-400000000
258maxx342 max 9e-999999998 0.01           ->  0.01
259maxx343 max 9e-999999998 0.1            ->  0.1
260maxx344 max 0.01 9e-999999998           ->  0.01
261maxx345 max 1e599999999 1e400000001     ->  1E+599999999
262maxx346 max 1e599999999 1e400000000     ->  1E+599999999
263maxx347 max 1e600000000 1e400000000     ->  1E+600000000
264maxx348 max 9e999999998 100             ->  9E+999999998
265maxx349 max 9e999999998 10              ->  9E+999999998
266maxx350 max 100  9e999999998            ->  9E+999999998
267-- signs
268maxx351 max  1e+777777777  1e+411111111 ->  1E+777777777
269maxx352 max  1e+777777777 -1e+411111111 ->  1E+777777777
270maxx353 max -1e+777777777  1e+411111111 ->  1E+411111111
271maxx354 max -1e+777777777 -1e+411111111 -> -1E+411111111
272maxx355 max  1e-777777777  1e-411111111 ->  1E-411111111
273maxx356 max  1e-777777777 -1e-411111111 ->  1E-777777777
274maxx357 max -1e-777777777  1e-411111111 ->  1E-411111111
275maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777
276
277-- expanded list from min/max 754r purple prose
278-- [explicit tests for exponent ordering]
279maxx401 max  Inf    1.1     ->  Infinity
280maxx402 max  1.1    1       ->  1.1
281maxx403 max  1      1.0     ->  1
282maxx404 max  1.0    0.1     ->  1.0
283maxx405 max  0.1    0.10    ->  0.1
284maxx406 max  0.10   0.100   ->  0.10
285maxx407 max  0.10   0       ->  0.10
286maxx408 max  0      0.0     ->  0
287maxx409 max  0.0   -0       ->  0.0
288maxx410 max  0.0   -0.0     ->  0.0
289maxx411 max  0.00  -0.0     ->  0.00
290maxx412 max  0.0   -0.00    ->  0.0
291maxx413 max  0     -0.0     ->  0
292maxx414 max  0     -0       ->  0
293maxx415 max -0.0   -0       -> -0.0
294maxx416 max -0     -0.100   -> -0
295maxx417 max -0.100 -0.10    -> -0.100
296maxx418 max -0.10  -0.1     -> -0.10
297maxx419 max -0.1   -1.0     -> -0.1
298maxx420 max -1.0   -1       -> -1.0
299maxx421 max -1     -1.1     -> -1
300maxx423 max -1.1   -Inf     -> -1.1
301-- same with operands reversed
302maxx431 max  1.1    Inf     ->  Infinity
303maxx432 max  1      1.1     ->  1.1
304maxx433 max  1.0    1       ->  1
305maxx434 max  0.1    1.0     ->  1.0
306maxx435 max  0.10   0.1     ->  0.1
307maxx436 max  0.100  0.10    ->  0.10
308maxx437 max  0      0.10    ->  0.10
309maxx438 max  0.0    0       ->  0
310maxx439 max -0      0.0     ->  0.0
311maxx440 max -0.0    0.0     ->  0.0
312maxx441 max -0.0    0.00    ->  0.00
313maxx442 max -0.00   0.0     ->  0.0
314maxx443 max -0.0    0       ->  0
315maxx444 max -0      0       ->  0
316maxx445 max -0     -0.0     -> -0.0
317maxx446 max -0.100 -0       -> -0
318maxx447 max -0.10  -0.100   -> -0.100
319maxx448 max -0.1   -0.10    -> -0.10
320maxx449 max -1.0   -0.1     -> -0.1
321maxx450 max -1     -1.0     -> -1.0
322maxx451 max -1.1   -1       -> -1
323maxx453 max -Inf   -1.1     -> -1.1
324-- largies
325maxx460 max  1000   1E+3    ->  1E+3
326maxx461 max  1E+3   1000    ->  1E+3
327maxx462 max  1000  -1E+3    ->  1000
328maxx463 max  1E+3  -1000    ->  1E+3
329maxx464 max -1000   1E+3    ->  1E+3
330maxx465 max -1E+3   1000    ->  1000
331maxx466 max -1000  -1E+3    -> -1000
332maxx467 max -1E+3  -1000    -> -1000
333
334-- rounding (results treated as though plus)
335maxexponent: 999999999
336minexponent: -999999999
337precision: 3
338
339maxx470 max  1      .5     ->  1
340maxx471 max  10     5      ->  10
341maxx472 max  100    50     ->  100
342maxx473 max  1000   500    ->  1.00E+3 Rounded
343maxx474 max  10000  5000   ->  1.00E+4 Rounded
344maxx475 max  6      .5     ->  6
345maxx476 max  66     5      ->  66
346maxx477 max  666    50     ->  666
347maxx478 max  6666   500    ->  6.67E+3 Rounded Inexact
348maxx479 max  66666  5000   ->  6.67E+4 Rounded Inexact
349maxx480 max  33333  5000   ->  3.33E+4 Rounded Inexact
350maxx481 max  .5     1      ->  1
351maxx482 max  .5     10     ->  10
352maxx483 max  .5     100    ->  100
353maxx484 max  .5     1000   ->  1.00E+3 Rounded
354maxx485 max  .5     10000  ->  1.00E+4 Rounded
355maxx486 max  .5     6      ->  6
356maxx487 max  .5     66     ->  66
357maxx488 max  .5     666    ->  666
358maxx489 max  .5     6666   ->  6.67E+3 Rounded Inexact
359maxx490 max  .5     66666  ->  6.67E+4 Rounded Inexact
360maxx491 max  .5     33333  ->  3.33E+4 Rounded Inexact
361
362-- overflow tests
363maxexponent: 999999999
364minexponent: -999999999
365precision: 3
366maxx500 max 9.999E+999999999  0 ->  Infinity Inexact Overflow Rounded
367maxx501 max -9.999E+999999999 0 ->  0
368
369-- subnormals and underflow
370precision: 3
371maxexponent: 999
372minexponent: -999
373maxx510 max  1.00E-999       0  ->   1.00E-999
374maxx511 max  0.1E-999        0  ->   1E-1000   Subnormal
375maxx512 max  0.10E-999       0  ->   1.0E-1000 Subnormal
376maxx513 max  0.100E-999      0  ->   1.0E-1000 Subnormal Rounded
377maxx514 max  0.01E-999       0  ->   1E-1001   Subnormal
378-- next is rounded to Nmin
379maxx515 max  0.999E-999      0  ->   1.00E-999 Inexact Rounded Subnormal Underflow
380maxx516 max  0.099E-999      0  ->   1.0E-1000 Inexact Rounded Subnormal Underflow
381maxx517 max  0.009E-999      0  ->   1E-1001   Inexact Rounded Subnormal Underflow
382maxx518 max  0.001E-999      0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
383maxx519 max  0.0009E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
384maxx520 max  0.0001E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
385
386maxx530 max -1.00E-999       0  ->   0
387maxx531 max -0.1E-999        0  ->   0
388maxx532 max -0.10E-999       0  ->   0
389maxx533 max -0.100E-999      0  ->   0
390maxx534 max -0.01E-999       0  ->   0
391maxx535 max -0.999E-999      0  ->   0
392maxx536 max -0.099E-999      0  ->   0
393maxx537 max -0.009E-999      0  ->   0
394maxx538 max -0.001E-999      0  ->   0
395maxx539 max -0.0009E-999     0  ->   0
396maxx540 max -0.0001E-999     0  ->   0
397
398-- misalignment traps for little-endian
399precision: 9
400maxx551 max      1.0       0.1  -> 1.0
401maxx552 max      0.1       1.0  -> 1.0
402maxx553 max     10.0       0.1  -> 10.0
403maxx554 max      0.1      10.0  -> 10.0
404maxx555 max      100       1.0  -> 100
405maxx556 max      1.0       100  -> 100
406maxx557 max     1000      10.0  -> 1000
407maxx558 max     10.0      1000  -> 1000
408maxx559 max    10000     100.0  -> 10000
409maxx560 max    100.0     10000  -> 10000
410maxx661 max   100000    1000.0  -> 100000
411maxx662 max   1000.0    100000  -> 100000
412maxx663 max  1000000   10000.0  -> 1000000
413maxx664 max  10000.0   1000000  -> 1000000
414
415-- payload decapitate
416precision: 5
417maxx670 max      11 -sNaN12345678901 -> -NaN78901  Invalid_operation
418
419-- Null tests
420maxx900 max 10  #  -> NaN Invalid_operation
421maxx901 max  # 10  -> NaN Invalid_operation
422
423
424
425