1------------------------------------------------------------------------ 2-- maxmag.decTest -- decimal maximum by magnitude -- 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 32mxgx001 maxmag -2 -2 -> -2 33mxgx002 maxmag -2 -1 -> -2 34mxgx003 maxmag -2 0 -> -2 35mxgx004 maxmag -2 1 -> -2 36mxgx005 maxmag -2 2 -> 2 37mxgx006 maxmag -1 -2 -> -2 38mxgx007 maxmag -1 -1 -> -1 39mxgx008 maxmag -1 0 -> -1 40mxgx009 maxmag -1 1 -> 1 41mxgx010 maxmag -1 2 -> 2 42mxgx011 maxmag 0 -2 -> -2 43mxgx012 maxmag 0 -1 -> -1 44mxgx013 maxmag 0 0 -> 0 45mxgx014 maxmag 0 1 -> 1 46mxgx015 maxmag 0 2 -> 2 47mxgx016 maxmag 1 -2 -> -2 48mxgx017 maxmag 1 -1 -> 1 49mxgx018 maxmag 1 0 -> 1 50mxgx019 maxmag 1 1 -> 1 51mxgx020 maxmag 1 2 -> 2 52mxgx021 maxmag 2 -2 -> 2 53mxgx022 maxmag 2 -1 -> 2 54mxgx023 maxmag 2 0 -> 2 55mxgx025 maxmag 2 1 -> 2 56mxgx026 maxmag 2 2 -> 2 57 58-- extended zeros 59mxgx030 maxmag 0 0 -> 0 60mxgx031 maxmag 0 -0 -> 0 61mxgx032 maxmag 0 -0.0 -> 0 62mxgx033 maxmag 0 0.0 -> 0 63mxgx034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen 64mxgx035 maxmag -0 -0 -> -0 65mxgx036 maxmag -0 -0.0 -> -0.0 66mxgx037 maxmag -0 0.0 -> 0.0 67mxgx038 maxmag 0.0 0 -> 0 68mxgx039 maxmag 0.0 -0 -> 0.0 69mxgx040 maxmag 0.0 -0.0 -> 0.0 70mxgx041 maxmag 0.0 0.0 -> 0.0 71mxgx042 maxmag -0.0 0 -> 0 72mxgx043 maxmag -0.0 -0 -> -0.0 73mxgx044 maxmag -0.0 -0.0 -> -0.0 74mxgx045 maxmag -0.0 0.0 -> 0.0 75 76mxgx050 maxmag -0E1 0E1 -> 0E+1 77mxgx051 maxmag -0E2 0E2 -> 0E+2 78mxgx052 maxmag -0E2 0E1 -> 0E+1 79mxgx053 maxmag -0E1 0E2 -> 0E+2 80mxgx054 maxmag 0E1 -0E1 -> 0E+1 81mxgx055 maxmag 0E2 -0E2 -> 0E+2 82mxgx056 maxmag 0E2 -0E1 -> 0E+2 83mxgx057 maxmag 0E1 -0E2 -> 0E+1 84 85mxgx058 maxmag 0E1 0E1 -> 0E+1 86mxgx059 maxmag 0E2 0E2 -> 0E+2 87mxgx060 maxmag 0E2 0E1 -> 0E+2 88mxgx061 maxmag 0E1 0E2 -> 0E+2 89mxgx062 maxmag -0E1 -0E1 -> -0E+1 90mxgx063 maxmag -0E2 -0E2 -> -0E+2 91mxgx064 maxmag -0E2 -0E1 -> -0E+1 92mxgx065 maxmag -0E1 -0E2 -> -0E+1 93 94-- Specials 95precision: 9 96mxgx090 maxmag Inf -Inf -> Infinity 97mxgx091 maxmag Inf -1000 -> Infinity 98mxgx092 maxmag Inf -1 -> Infinity 99mxgx093 maxmag Inf -0 -> Infinity 100mxgx094 maxmag Inf 0 -> Infinity 101mxgx095 maxmag Inf 1 -> Infinity 102mxgx096 maxmag Inf 1000 -> Infinity 103mxgx097 maxmag Inf Inf -> Infinity 104mxgx098 maxmag -1000 Inf -> Infinity 105mxgx099 maxmag -Inf Inf -> Infinity 106mxgx100 maxmag -1 Inf -> Infinity 107mxgx101 maxmag -0 Inf -> Infinity 108mxgx102 maxmag 0 Inf -> Infinity 109mxgx103 maxmag 1 Inf -> Infinity 110mxgx104 maxmag 1000 Inf -> Infinity 111mxgx105 maxmag Inf Inf -> Infinity 112 113mxgx120 maxmag -Inf -Inf -> -Infinity 114mxgx121 maxmag -Inf -1000 -> -Infinity 115mxgx122 maxmag -Inf -1 -> -Infinity 116mxgx123 maxmag -Inf -0 -> -Infinity 117mxgx124 maxmag -Inf 0 -> -Infinity 118mxgx125 maxmag -Inf 1 -> -Infinity 119mxgx126 maxmag -Inf 1000 -> -Infinity 120mxgx127 maxmag -Inf Inf -> Infinity 121mxgx128 maxmag -Inf -Inf -> -Infinity 122mxgx129 maxmag -1000 -Inf -> -Infinity 123mxgx130 maxmag -1 -Inf -> -Infinity 124mxgx131 maxmag -0 -Inf -> -Infinity 125mxgx132 maxmag 0 -Inf -> -Infinity 126mxgx133 maxmag 1 -Inf -> -Infinity 127mxgx134 maxmag 1000 -Inf -> -Infinity 128mxgx135 maxmag Inf -Inf -> Infinity 129 130-- 2004.08.02 754r chooses number over NaN in mixed cases 131mxgx141 maxmag NaN -Inf -> -Infinity 132mxgx142 maxmag NaN -1000 -> -1000 133mxgx143 maxmag NaN -1 -> -1 134mxgx144 maxmag NaN -0 -> -0 135mxgx145 maxmag NaN 0 -> 0 136mxgx146 maxmag NaN 1 -> 1 137mxgx147 maxmag NaN 1000 -> 1000 138mxgx148 maxmag NaN Inf -> Infinity 139mxgx149 maxmag NaN NaN -> NaN 140mxgx150 maxmag -Inf NaN -> -Infinity 141mxgx151 maxmag -1000 NaN -> -1000 142mxgx152 maxmag -1 NaN -> -1 143mxgx153 maxmag -0 NaN -> -0 144mxgx154 maxmag 0 NaN -> 0 145mxgx155 maxmag 1 NaN -> 1 146mxgx156 maxmag 1000 NaN -> 1000 147mxgx157 maxmag Inf NaN -> Infinity 148 149mxgx161 maxmag sNaN -Inf -> NaN Invalid_operation 150mxgx162 maxmag sNaN -1000 -> NaN Invalid_operation 151mxgx163 maxmag sNaN -1 -> NaN Invalid_operation 152mxgx164 maxmag sNaN -0 -> NaN Invalid_operation 153mxgx165 maxmag sNaN 0 -> NaN Invalid_operation 154mxgx166 maxmag sNaN 1 -> NaN Invalid_operation 155mxgx167 maxmag sNaN 1000 -> NaN Invalid_operation 156mxgx168 maxmag sNaN NaN -> NaN Invalid_operation 157mxgx169 maxmag sNaN sNaN -> NaN Invalid_operation 158mxgx170 maxmag NaN sNaN -> NaN Invalid_operation 159mxgx171 maxmag -Inf sNaN -> NaN Invalid_operation 160mxgx172 maxmag -1000 sNaN -> NaN Invalid_operation 161mxgx173 maxmag -1 sNaN -> NaN Invalid_operation 162mxgx174 maxmag -0 sNaN -> NaN Invalid_operation 163mxgx175 maxmag 0 sNaN -> NaN Invalid_operation 164mxgx176 maxmag 1 sNaN -> NaN Invalid_operation 165mxgx177 maxmag 1000 sNaN -> NaN Invalid_operation 166mxgx178 maxmag Inf sNaN -> NaN Invalid_operation 167mxgx179 maxmag NaN sNaN -> NaN Invalid_operation 168 169-- propagating NaNs 170mxgx181 maxmag NaN9 -Inf -> -Infinity 171mxgx182 maxmag NaN8 9 -> 9 172mxgx183 maxmag -NaN7 Inf -> Infinity 173 174mxgx184 maxmag -NaN1 NaN11 -> -NaN1 175mxgx185 maxmag NaN2 NaN12 -> NaN2 176mxgx186 maxmag -NaN13 -NaN7 -> -NaN13 177mxgx187 maxmag NaN14 -NaN5 -> NaN14 178 179mxgx188 maxmag -Inf NaN4 -> -Infinity 180mxgx189 maxmag -9 -NaN3 -> -9 181mxgx190 maxmag Inf NaN2 -> Infinity 182 183mxgx191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation 184mxgx192 maxmag sNaN98 -1 -> NaN98 Invalid_operation 185mxgx193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation 186mxgx194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation 187mxgx195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation 188mxgx196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation 189mxgx197 maxmag 0 sNaN91 -> NaN91 Invalid_operation 190mxgx198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation 191mxgx199 maxmag NaN sNaN89 -> NaN89 Invalid_operation 192 193-- rounding checks 194maxexponent: 999 195minexponent: -999 196precision: 9 197mxgx201 maxmag 12345678000 1 -> 1.23456780E+10 Rounded 198mxgx202 maxmag 1 12345678000 -> 1.23456780E+10 Rounded 199mxgx203 maxmag 1234567800 1 -> 1.23456780E+9 Rounded 200mxgx204 maxmag 1 1234567800 -> 1.23456780E+9 Rounded 201mxgx205 maxmag 1234567890 1 -> 1.23456789E+9 Rounded 202mxgx206 maxmag 1 1234567890 -> 1.23456789E+9 Rounded 203mxgx207 maxmag 1234567891 1 -> 1.23456789E+9 Inexact Rounded 204mxgx208 maxmag 1 1234567891 -> 1.23456789E+9 Inexact Rounded 205mxgx209 maxmag 12345678901 1 -> 1.23456789E+10 Inexact Rounded 206mxgx210 maxmag 1 12345678901 -> 1.23456789E+10 Inexact Rounded 207mxgx211 maxmag 1234567896 1 -> 1.23456790E+9 Inexact Rounded 208mxgx212 maxmag 1 1234567896 -> 1.23456790E+9 Inexact Rounded 209mxgx213 maxmag -1234567891 1 -> -1.23456789E+9 Inexact Rounded 210mxgx214 maxmag 1 -1234567891 -> -1.23456789E+9 Inexact Rounded 211mxgx215 maxmag -12345678901 1 -> -1.23456789E+10 Inexact Rounded 212mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10 Inexact Rounded 213mxgx217 maxmag -1234567896 1 -> -1.23456790E+9 Inexact Rounded 214mxgx218 maxmag 1 -1234567896 -> -1.23456790E+9 Inexact Rounded 215 216precision: 15 217mxgx221 maxmag 12345678000 1 -> 12345678000 218mxgx222 maxmag 1 12345678000 -> 12345678000 219mxgx223 maxmag 1234567800 1 -> 1234567800 220mxgx224 maxmag 1 1234567800 -> 1234567800 221mxgx225 maxmag 1234567890 1 -> 1234567890 222mxgx226 maxmag 1 1234567890 -> 1234567890 223mxgx227 maxmag 1234567891 1 -> 1234567891 224mxgx228 maxmag 1 1234567891 -> 1234567891 225mxgx229 maxmag 12345678901 1 -> 12345678901 226mxgx230 maxmag 1 12345678901 -> 12345678901 227mxgx231 maxmag 1234567896 1 -> 1234567896 228mxgx232 maxmag 1 1234567896 -> 1234567896 229mxgx233 maxmag -1234567891 1 -> -1234567891 230mxgx234 maxmag 1 -1234567891 -> -1234567891 231mxgx235 maxmag -12345678901 1 -> -12345678901 232mxgx236 maxmag 1 -12345678901 -> -12345678901 233mxgx237 maxmag -1234567896 1 -> -1234567896 234mxgx238 maxmag 1 -1234567896 -> -1234567896 235 236-- from examples 237mxgx280 maxmag '3' '2' -> '3' 238mxgx281 maxmag '-10' '3' -> '-10' 239mxgx282 maxmag '1.0' '1' -> '1' 240mxgx283 maxmag '1' '1.0' -> '1' 241mxgx284 maxmag '7' 'NaN' -> '7' 242 243-- overflow and underflow tests ... 244maxExponent: 999999999 245minexponent: -999999999 246mxgx330 maxmag +1.23456789012345E-0 9E+999999999 -> 9E+999999999 247mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 -> 9E+999999999 248mxgx332 maxmag +0.100 9E-999999999 -> 0.100 249mxgx333 maxmag 9E-999999999 +0.100 -> 0.100 250mxgx335 maxmag -1.23456789012345E-0 9E+999999999 -> 9E+999999999 251mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 -> 9E+999999999 252mxgx337 maxmag -0.100 9E-999999999 -> -0.100 253mxgx338 maxmag 9E-999999999 -0.100 -> -0.100 254 255mxgx339 maxmag 1e-599999999 1e-400000001 -> 1E-400000001 256mxgx340 maxmag 1e-599999999 1e-400000000 -> 1E-400000000 257mxgx341 maxmag 1e-600000000 1e-400000000 -> 1E-400000000 258mxgx342 maxmag 9e-999999998 0.01 -> 0.01 259mxgx343 maxmag 9e-999999998 0.1 -> 0.1 260mxgx344 maxmag 0.01 9e-999999998 -> 0.01 261mxgx345 maxmag 1e599999999 1e400000001 -> 1E+599999999 262mxgx346 maxmag 1e599999999 1e400000000 -> 1E+599999999 263mxgx347 maxmag 1e600000000 1e400000000 -> 1E+600000000 264mxgx348 maxmag 9e999999998 100 -> 9E+999999998 265mxgx349 maxmag 9e999999998 10 -> 9E+999999998 266mxgx350 maxmag 100 9e999999998 -> 9E+999999998 267-- signs 268mxgx351 maxmag 1e+777777777 1e+411111111 -> 1E+777777777 269mxgx352 maxmag 1e+777777777 -1e+411111111 -> 1E+777777777 270mxgx353 maxmag -1e+777777777 1e+411111111 -> -1E+777777777 271mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777 272mxgx355 maxmag 1e-777777777 1e-411111111 -> 1E-411111111 273mxgx356 maxmag 1e-777777777 -1e-411111111 -> -1E-411111111 274mxgx357 maxmag -1e-777777777 1e-411111111 -> 1E-411111111 275mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111 276 277-- expanded list from min/max 754r purple prose 278-- [explicit tests for exponent ordering] 279mxgx401 maxmag Inf 1.1 -> Infinity 280mxgx402 maxmag 1.1 1 -> 1.1 281mxgx403 maxmag 1 1.0 -> 1 282mxgx404 maxmag 1.0 0.1 -> 1.0 283mxgx405 maxmag 0.1 0.10 -> 0.1 284mxgx406 maxmag 0.10 0.100 -> 0.10 285mxgx407 maxmag 0.10 0 -> 0.10 286mxgx408 maxmag 0 0.0 -> 0 287mxgx409 maxmag 0.0 -0 -> 0.0 288mxgx410 maxmag 0.0 -0.0 -> 0.0 289mxgx411 maxmag 0.00 -0.0 -> 0.00 290mxgx412 maxmag 0.0 -0.00 -> 0.0 291mxgx413 maxmag 0 -0.0 -> 0 292mxgx414 maxmag 0 -0 -> 0 293mxgx415 maxmag -0.0 -0 -> -0.0 294mxgx416 maxmag -0 -0.100 -> -0.100 295mxgx417 maxmag -0.100 -0.10 -> -0.100 296mxgx418 maxmag -0.10 -0.1 -> -0.10 297mxgx419 maxmag -0.1 -1.0 -> -1.0 298mxgx420 maxmag -1.0 -1 -> -1.0 299mxgx421 maxmag -1 -1.1 -> -1.1 300mxgx423 maxmag -1.1 -Inf -> -Infinity 301-- same with operands reversed 302mxgx431 maxmag 1.1 Inf -> Infinity 303mxgx432 maxmag 1 1.1 -> 1.1 304mxgx433 maxmag 1.0 1 -> 1 305mxgx434 maxmag 0.1 1.0 -> 1.0 306mxgx435 maxmag 0.10 0.1 -> 0.1 307mxgx436 maxmag 0.100 0.10 -> 0.10 308mxgx437 maxmag 0 0.10 -> 0.10 309mxgx438 maxmag 0.0 0 -> 0 310mxgx439 maxmag -0 0.0 -> 0.0 311mxgx440 maxmag -0.0 0.0 -> 0.0 312mxgx441 maxmag -0.0 0.00 -> 0.00 313mxgx442 maxmag -0.00 0.0 -> 0.0 314mxgx443 maxmag -0.0 0 -> 0 315mxgx444 maxmag -0 0 -> 0 316mxgx445 maxmag -0 -0.0 -> -0.0 317mxgx446 maxmag -0.100 -0 -> -0.100 318mxgx447 maxmag -0.10 -0.100 -> -0.100 319mxgx448 maxmag -0.1 -0.10 -> -0.10 320mxgx449 maxmag -1.0 -0.1 -> -1.0 321mxgx450 maxmag -1 -1.0 -> -1.0 322mxgx451 maxmag -1.1 -1 -> -1.1 323mxgx453 maxmag -Inf -1.1 -> -Infinity 324-- largies 325mxgx460 maxmag 1000 1E+3 -> 1E+3 326mxgx461 maxmag 1E+3 1000 -> 1E+3 327mxgx462 maxmag 1000 -1E+3 -> 1000 328mxgx463 maxmag 1E+3 -1000 -> 1E+3 329mxgx464 maxmag -1000 1E+3 -> 1E+3 330mxgx465 maxmag -1E+3 1000 -> 1000 331mxgx466 maxmag -1000 -1E+3 -> -1000 332mxgx467 maxmag -1E+3 -1000 -> -1000 333 334-- rounding (results treated as though plus) 335maxexponent: 999999999 336minexponent: -999999999 337precision: 3 338 339mxgx470 maxmag 1 .5 -> 1 340mxgx471 maxmag 10 5 -> 10 341mxgx472 maxmag 100 50 -> 100 342mxgx473 maxmag 1000 500 -> 1.00E+3 Rounded 343mxgx474 maxmag 10000 5000 -> 1.00E+4 Rounded 344mxgx475 maxmag 6 .5 -> 6 345mxgx476 maxmag 66 5 -> 66 346mxgx477 maxmag 666 50 -> 666 347mxgx478 maxmag 6666 500 -> 6.67E+3 Rounded Inexact 348mxgx479 maxmag 66666 5000 -> 6.67E+4 Rounded Inexact 349mxgx480 maxmag 33333 5000 -> 3.33E+4 Rounded Inexact 350mxgx481 maxmag .5 1 -> 1 351mxgx482 maxmag .5 10 -> 10 352mxgx483 maxmag .5 100 -> 100 353mxgx484 maxmag .5 1000 -> 1.00E+3 Rounded 354mxgx485 maxmag .5 10000 -> 1.00E+4 Rounded 355mxgx486 maxmag .5 6 -> 6 356mxgx487 maxmag .5 66 -> 66 357mxgx488 maxmag .5 666 -> 666 358mxgx489 maxmag .5 6666 -> 6.67E+3 Rounded Inexact 359mxgx490 maxmag .5 66666 -> 6.67E+4 Rounded Inexact 360mxgx491 maxmag .5 33333 -> 3.33E+4 Rounded Inexact 361 362-- overflow tests 363maxexponent: 999999999 364minexponent: -999999999 365precision: 3 366mxgx500 maxmag 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded 367mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded 368 369-- subnormals and underflow 370precision: 3 371maxexponent: 999 372minexponent: -999 373mxgx510 maxmag 1.00E-999 0 -> 1.00E-999 374mxgx511 maxmag 0.1E-999 0 -> 1E-1000 Subnormal 375mxgx512 maxmag 0.10E-999 0 -> 1.0E-1000 Subnormal 376mxgx513 maxmag 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded 377mxgx514 maxmag 0.01E-999 0 -> 1E-1001 Subnormal 378-- next is rounded to Nmin 379mxgx515 maxmag 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow 380mxgx516 maxmag 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow 381mxgx517 maxmag 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow 382mxgx518 maxmag 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 383mxgx519 maxmag 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 384mxgx520 maxmag 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 385 386mxgx530 maxmag -1.00E-999 0 -> -1.00E-999 387mxgx531 maxmag -0.1E-999 0 -> -1E-1000 Subnormal 388mxgx532 maxmag -0.10E-999 0 -> -1.0E-1000 Subnormal 389mxgx533 maxmag -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded 390mxgx534 maxmag -0.01E-999 0 -> -1E-1001 Subnormal 391-- next is rounded to -Nmin 392mxgx535 maxmag -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow 393mxgx536 maxmag -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow 394mxgx537 maxmag -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow 395mxgx538 maxmag -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 396mxgx539 maxmag -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 397mxgx540 maxmag -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 398 399-- Null tests 400mxgx900 maxmag 10 # -> NaN Invalid_operation 401mxgx901 maxmag # 10 -> NaN Invalid_operation 402 403 404 405