Raymond Hettinger | 7c85fa4 | 2004-07-01 11:01:35 +0000 | [diff] [blame^] | 1 | ------------------------------------------------------------------------ |
| 2 | -- max.decTest -- decimal maximum -- |
| 3 | -- Copyright (c) IBM Corporation, 1981, 2004. 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 | ------------------------------------------------------------------------ |
| 20 | version: 2.38 |
| 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 |
| 64 | maxx035 max -0 -0 -> -0 |
| 65 | maxx036 max -0 -0.0 -> -0 |
| 66 | maxx037 max -0 0.0 -> -0 |
| 67 | maxx038 max 0.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.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 | maxx046 max -0E1 0E2 -> -0E+1 |
| 77 | maxx047 max 0E2 0E1 -> 0E+2 |
| 78 | maxx048 max 0E1 0E2 -> 0E+1 |
| 79 | maxx049 max -0E3 -0E2 -> -0E+3 |
| 80 | |
| 81 | |
| 82 | -- Specials |
| 83 | precision: 9 |
| 84 | maxx090 max Inf -Inf -> Infinity |
| 85 | maxx091 max Inf -1000 -> Infinity |
| 86 | maxx092 max Inf -1 -> Infinity |
| 87 | maxx093 max Inf -0 -> Infinity |
| 88 | maxx094 max Inf 0 -> Infinity |
| 89 | maxx095 max Inf 1 -> Infinity |
| 90 | maxx096 max Inf 1000 -> Infinity |
| 91 | maxx097 max Inf Inf -> Infinity |
| 92 | maxx098 max -1000 Inf -> Infinity |
| 93 | maxx099 max -Inf Inf -> Infinity |
| 94 | maxx100 max -1 Inf -> Infinity |
| 95 | maxx101 max -0 Inf -> Infinity |
| 96 | maxx102 max 0 Inf -> Infinity |
| 97 | maxx103 max 1 Inf -> Infinity |
| 98 | maxx104 max 1000 Inf -> Infinity |
| 99 | maxx105 max Inf Inf -> Infinity |
| 100 | |
| 101 | maxx120 max -Inf -Inf -> -Infinity |
| 102 | maxx121 max -Inf -1000 -> -1000 |
| 103 | maxx122 max -Inf -1 -> -1 |
| 104 | maxx123 max -Inf -0 -> -0 |
| 105 | maxx124 max -Inf 0 -> 0 |
| 106 | maxx125 max -Inf 1 -> 1 |
| 107 | maxx126 max -Inf 1000 -> 1000 |
| 108 | maxx127 max -Inf Inf -> Infinity |
| 109 | maxx128 max -Inf -Inf -> -Infinity |
| 110 | maxx129 max -1000 -Inf -> -1000 |
| 111 | maxx130 max -1 -Inf -> -1 |
| 112 | maxx131 max -0 -Inf -> -0 |
| 113 | maxx132 max 0 -Inf -> 0 |
| 114 | maxx133 max 1 -Inf -> 1 |
| 115 | maxx134 max 1000 -Inf -> 1000 |
| 116 | maxx135 max Inf -Inf -> Infinity |
| 117 | |
| 118 | maxx141 max NaN -Inf -> NaN |
| 119 | maxx142 max NaN -1000 -> NaN |
| 120 | maxx143 max NaN -1 -> NaN |
| 121 | maxx144 max NaN -0 -> NaN |
| 122 | maxx145 max NaN 0 -> NaN |
| 123 | maxx146 max NaN 1 -> NaN |
| 124 | maxx147 max NaN 1000 -> NaN |
| 125 | maxx148 max NaN Inf -> NaN |
| 126 | maxx149 max NaN NaN -> NaN |
| 127 | maxx150 max -Inf NaN -> NaN |
| 128 | maxx151 max -1000 NaN -> NaN |
| 129 | maxx152 max -1 NaN -> NaN |
| 130 | maxx153 max -0 NaN -> NaN |
| 131 | maxx154 max 0 NaN -> NaN |
| 132 | maxx155 max 1 NaN -> NaN |
| 133 | maxx156 max 1000 NaN -> NaN |
| 134 | maxx157 max Inf NaN -> NaN |
| 135 | |
| 136 | maxx161 max sNaN -Inf -> NaN Invalid_operation |
| 137 | maxx162 max sNaN -1000 -> NaN Invalid_operation |
| 138 | maxx163 max sNaN -1 -> NaN Invalid_operation |
| 139 | maxx164 max sNaN -0 -> NaN Invalid_operation |
| 140 | maxx165 max sNaN 0 -> NaN Invalid_operation |
| 141 | maxx166 max sNaN 1 -> NaN Invalid_operation |
| 142 | maxx167 max sNaN 1000 -> NaN Invalid_operation |
| 143 | maxx168 max sNaN NaN -> NaN Invalid_operation |
| 144 | maxx169 max sNaN sNaN -> NaN Invalid_operation |
| 145 | maxx170 max NaN sNaN -> NaN Invalid_operation |
| 146 | maxx171 max -Inf sNaN -> NaN Invalid_operation |
| 147 | maxx172 max -1000 sNaN -> NaN Invalid_operation |
| 148 | maxx173 max -1 sNaN -> NaN Invalid_operation |
| 149 | maxx174 max -0 sNaN -> NaN Invalid_operation |
| 150 | maxx175 max 0 sNaN -> NaN Invalid_operation |
| 151 | maxx176 max 1 sNaN -> NaN Invalid_operation |
| 152 | maxx177 max 1000 sNaN -> NaN Invalid_operation |
| 153 | maxx178 max Inf sNaN -> NaN Invalid_operation |
| 154 | maxx179 max NaN sNaN -> NaN Invalid_operation |
| 155 | |
| 156 | -- propagating NaNs |
| 157 | maxx181 max NaN9 -Inf -> NaN9 |
| 158 | maxx182 max NaN8 9 -> NaN8 |
| 159 | maxx183 max -NaN7 Inf -> -NaN7 |
| 160 | maxx184 max NaN6 NaN5 -> NaN6 |
| 161 | maxx185 max -Inf NaN4 -> NaN4 |
| 162 | maxx186 max -9 -NaN3 -> -NaN3 |
| 163 | maxx187 max Inf NaN2 -> NaN2 |
| 164 | |
| 165 | maxx191 max sNaN99 -Inf -> NaN99 Invalid_operation |
| 166 | maxx192 max sNaN98 -1 -> NaN98 Invalid_operation |
| 167 | maxx193 max -sNaN97 NaN -> -NaN97 Invalid_operation |
| 168 | maxx194 max sNaN96 sNaN94 -> NaN96 Invalid_operation |
| 169 | maxx195 max NaN95 sNaN93 -> NaN93 Invalid_operation |
| 170 | maxx196 max -Inf sNaN92 -> NaN92 Invalid_operation |
| 171 | maxx197 max 0 sNaN91 -> NaN91 Invalid_operation |
| 172 | maxx198 max Inf -sNaN90 -> -NaN90 Invalid_operation |
| 173 | maxx199 max NaN sNaN89 -> NaN89 Invalid_operation |
| 174 | |
| 175 | -- rounding checks |
| 176 | maxexponent: 999 |
| 177 | minexponent: -999 |
| 178 | precision: 9 |
| 179 | maxx201 max 12345678000 1 -> 1.23456780E+10 Rounded |
| 180 | maxx202 max 1 12345678000 -> 1.23456780E+10 Rounded |
| 181 | maxx203 max 1234567800 1 -> 1.23456780E+9 Rounded |
| 182 | maxx204 max 1 1234567800 -> 1.23456780E+9 Rounded |
| 183 | maxx205 max 1234567890 1 -> 1.23456789E+9 Rounded |
| 184 | maxx206 max 1 1234567890 -> 1.23456789E+9 Rounded |
| 185 | maxx207 max 1234567891 1 -> 1.23456789E+9 Inexact Rounded |
| 186 | maxx208 max 1 1234567891 -> 1.23456789E+9 Inexact Rounded |
| 187 | maxx209 max 12345678901 1 -> 1.23456789E+10 Inexact Rounded |
| 188 | maxx210 max 1 12345678901 -> 1.23456789E+10 Inexact Rounded |
| 189 | maxx211 max 1234567896 1 -> 1.23456790E+9 Inexact Rounded |
| 190 | maxx212 max 1 1234567896 -> 1.23456790E+9 Inexact Rounded |
| 191 | maxx213 max -1234567891 1 -> 1 |
| 192 | maxx214 max 1 -1234567891 -> 1 |
| 193 | maxx215 max -12345678901 1 -> 1 |
| 194 | maxx216 max 1 -12345678901 -> 1 |
| 195 | maxx217 max -1234567896 1 -> 1 |
| 196 | maxx218 max 1 -1234567896 -> 1 |
| 197 | |
| 198 | precision: 15 |
| 199 | maxx221 max 12345678000 1 -> 12345678000 |
| 200 | maxx222 max 1 12345678000 -> 12345678000 |
| 201 | maxx223 max 1234567800 1 -> 1234567800 |
| 202 | maxx224 max 1 1234567800 -> 1234567800 |
| 203 | maxx225 max 1234567890 1 -> 1234567890 |
| 204 | maxx226 max 1 1234567890 -> 1234567890 |
| 205 | maxx227 max 1234567891 1 -> 1234567891 |
| 206 | maxx228 max 1 1234567891 -> 1234567891 |
| 207 | maxx229 max 12345678901 1 -> 12345678901 |
| 208 | maxx230 max 1 12345678901 -> 12345678901 |
| 209 | maxx231 max 1234567896 1 -> 1234567896 |
| 210 | maxx232 max 1 1234567896 -> 1234567896 |
| 211 | maxx233 max -1234567891 1 -> 1 |
| 212 | maxx234 max 1 -1234567891 -> 1 |
| 213 | maxx235 max -12345678901 1 -> 1 |
| 214 | maxx236 max 1 -12345678901 -> 1 |
| 215 | maxx237 max -1234567896 1 -> 1 |
| 216 | maxx238 max 1 -1234567896 -> 1 |
| 217 | |
| 218 | -- from examples |
| 219 | maxx280 max '3' '2' -> '3' |
| 220 | maxx281 max '-10' '3' -> '3' |
| 221 | maxx282 max '1.0' '1' -> '1.0' |
| 222 | maxx283 max '1' '1.0' -> '1' |
| 223 | |
| 224 | -- overflow and underflow tests ... |
| 225 | maxExponent: 999999999 |
| 226 | minexponent: -999999999 |
| 227 | maxx330 max +1.23456789012345E-0 9E+999999999 -> 9E+999999999 |
| 228 | maxx331 max 9E+999999999 +1.23456789012345E-0 -> 9E+999999999 |
| 229 | maxx332 max +0.100 9E-999999999 -> 0.100 |
| 230 | maxx333 max 9E-999999999 +0.100 -> 0.100 |
| 231 | maxx335 max -1.23456789012345E-0 9E+999999999 -> 9E+999999999 |
| 232 | maxx336 max 9E+999999999 -1.23456789012345E-0 -> 9E+999999999 |
| 233 | maxx337 max -0.100 9E-999999999 -> 9E-999999999 |
| 234 | maxx338 max 9E-999999999 -0.100 -> 9E-999999999 |
| 235 | |
| 236 | maxx339 max 1e-599999999 1e-400000001 -> 1E-400000001 |
| 237 | maxx340 max 1e-599999999 1e-400000000 -> 1E-400000000 |
| 238 | maxx341 max 1e-600000000 1e-400000000 -> 1E-400000000 |
| 239 | maxx342 max 9e-999999998 0.01 -> 0.01 |
| 240 | maxx343 max 9e-999999998 0.1 -> 0.1 |
| 241 | maxx344 max 0.01 9e-999999998 -> 0.01 |
| 242 | maxx345 max 1e599999999 1e400000001 -> 1E+599999999 |
| 243 | maxx346 max 1e599999999 1e400000000 -> 1E+599999999 |
| 244 | maxx347 max 1e600000000 1e400000000 -> 1E+600000000 |
| 245 | maxx348 max 9e999999998 100 -> 9E+999999998 |
| 246 | maxx349 max 9e999999998 10 -> 9E+999999998 |
| 247 | maxx350 max 100 9e999999998 -> 9E+999999998 |
| 248 | -- signs |
| 249 | maxx351 max 1e+777777777 1e+411111111 -> 1E+777777777 |
| 250 | maxx352 max 1e+777777777 -1e+411111111 -> 1E+777777777 |
| 251 | maxx353 max -1e+777777777 1e+411111111 -> 1E+411111111 |
| 252 | maxx354 max -1e+777777777 -1e+411111111 -> -1E+411111111 |
| 253 | maxx355 max 1e-777777777 1e-411111111 -> 1E-411111111 |
| 254 | maxx356 max 1e-777777777 -1e-411111111 -> 1E-777777777 |
| 255 | maxx357 max -1e-777777777 1e-411111111 -> 1E-411111111 |
| 256 | maxx358 max -1e-777777777 -1e-411111111 -> -1E-777777777 |
| 257 | |
| 258 | |
| 259 | -- overflow tests |
| 260 | maxexponent: 999999999 |
| 261 | minexponent: -999999999 |
| 262 | precision: 3 |
| 263 | maxx400 max 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded |
| 264 | maxx401 max -9.999E+999999999 0 -> 0 |
| 265 | |
| 266 | -- subnormals and underflow |
| 267 | precision: 3 |
| 268 | maxexponent: 999 |
| 269 | minexponent: -999 |
| 270 | maxx410 max 1.00E-999 0 -> 1.00E-999 |
| 271 | maxx411 max 0.1E-999 0 -> 1E-1000 Subnormal |
| 272 | maxx412 max 0.10E-999 0 -> 1.0E-1000 Subnormal |
| 273 | maxx413 max 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded |
| 274 | maxx414 max 0.01E-999 0 -> 1E-1001 Subnormal |
| 275 | -- next is rounded to Emin |
| 276 | maxx415 max 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow |
| 277 | maxx416 max 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow |
| 278 | maxx417 max 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow |
| 279 | maxx418 max 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow |
| 280 | maxx419 max 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow |
| 281 | maxx420 max 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow |
| 282 | |
| 283 | maxx430 max -1.00E-999 0 -> 0 |
| 284 | maxx431 max -0.1E-999 0 -> 0 |
| 285 | maxx432 max -0.10E-999 0 -> 0 |
| 286 | maxx433 max -0.100E-999 0 -> 0 |
| 287 | maxx434 max -0.01E-999 0 -> 0 |
| 288 | maxx435 max -0.999E-999 0 -> 0 |
| 289 | maxx436 max -0.099E-999 0 -> 0 |
| 290 | maxx437 max -0.009E-999 0 -> 0 |
| 291 | maxx438 max -0.001E-999 0 -> 0 |
| 292 | maxx439 max -0.0009E-999 0 -> 0 |
| 293 | maxx440 max -0.0001E-999 0 -> 0 |
| 294 | |
| 295 | -- Null tests |
| 296 | maxx900 max 10 # -> NaN Invalid_operation |
| 297 | maxx901 max # 10 -> NaN Invalid_operation |
| 298 | |
| 299 | |
| 300 | |