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