Thomas Wouters | 1b7f891 | 2007-09-19 03:06:30 +0000 | [diff] [blame] | 1 | ------------------------------------------------------------------------
|
| 2 | -- dsEncode.decTest -- decimal four-byte format testcases --
|
Benjamin Peterson | f17ff4e | 2008-07-31 16:32:12 +0000 | [diff] [blame] | 3 | -- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
|
Thomas Wouters | 1b7f891 | 2007-09-19 03:06:30 +0000 | [diff] [blame] | 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 | -- [Previously called decimal32.decTest]
|
Mark Dickinson | 8a54653 | 2009-10-08 16:30:38 +0000 | [diff] [blame] | 21 | version: 2.59
|
Thomas Wouters | 1b7f891 | 2007-09-19 03:06:30 +0000 | [diff] [blame] | 22 |
|
| 23 | -- This set of tests is for the four-byte concrete representation.
|
| 24 | -- Its characteristics are:
|
| 25 | --
|
| 26 | -- 1 bit sign
|
| 27 | -- 5 bits combination field
|
| 28 | -- 6 bits exponent continuation
|
| 29 | -- 20 bits coefficient continuation
|
| 30 | --
|
| 31 | -- Total exponent length 8 bits
|
| 32 | -- Total coefficient length 24 bits (7 digits)
|
| 33 | --
|
| 34 | -- Elimit = 191 (maximum encoded exponent)
|
| 35 | -- Emax = 96 (largest exponent value)
|
| 36 | -- Emin = -95 (smallest exponent value)
|
| 37 | -- bias = 101 (subtracted from encoded exponent) = -Etiny
|
| 38 |
|
| 39 | -- The testcases here have only exactly representable data on the
|
| 40 | -- 'left-hand-side'; rounding from strings is tested in 'base'
|
| 41 | -- testcase groups.
|
| 42 |
|
| 43 | extended: 1
|
| 44 | clamp: 1
|
| 45 | precision: 7
|
| 46 | rounding: half_up
|
| 47 | maxExponent: 96
|
| 48 | minExponent: -95
|
| 49 |
|
| 50 | -- General testcases
|
| 51 | -- (mostly derived from the Strawman 4 document and examples)
|
| 52 | decs001 apply #A23003D0 -> -7.50
|
| 53 | decs002 apply -7.50 -> #A23003D0
|
| 54 | -- derivative canonical plain strings
|
| 55 | decs003 apply #A26003D0 -> -7.50E+3
|
| 56 | decs004 apply -7.50E+3 -> #A26003D0
|
| 57 | decs005 apply #A25003D0 -> -750
|
| 58 | decs006 apply -750 -> #A25003D0
|
| 59 | decs007 apply #A24003D0 -> -75.0
|
| 60 | decs008 apply -75.0 -> #A24003D0
|
| 61 | decs009 apply #A22003D0 -> -0.750
|
| 62 | decs010 apply -0.750 -> #A22003D0
|
| 63 | decs011 apply #A21003D0 -> -0.0750
|
| 64 | decs012 apply -0.0750 -> #A21003D0
|
| 65 | decs013 apply #A1f003D0 -> -0.000750
|
| 66 | decs014 apply -0.000750 -> #A1f003D0
|
| 67 | decs015 apply #A1d003D0 -> -0.00000750
|
| 68 | decs016 apply -0.00000750 -> #A1d003D0
|
| 69 | decs017 apply #A1c003D0 -> -7.50E-7
|
| 70 | decs018 apply -7.50E-7 -> #A1c003D0
|
| 71 |
|
| 72 | -- Normality
|
| 73 | decs020 apply 1234567 -> #2654d2e7
|
| 74 | decs021 apply -1234567 -> #a654d2e7
|
| 75 | decs022 apply 1111111 -> #26524491
|
| 76 |
|
| 77 | -- Nmax and similar
|
| 78 | decs031 apply 9.999999E+96 -> #77f3fcff
|
| 79 | decs032 apply #77f3fcff -> 9.999999E+96
|
| 80 | decs033 apply 1.234567E+96 -> #47f4d2e7
|
| 81 | decs034 apply #47f4d2e7 -> 1.234567E+96
|
| 82 | -- fold-downs (more below)
|
| 83 | decs035 apply 1.23E+96 -> #47f4c000 Clamped
|
| 84 | decs036 apply #47f4c000 -> 1.230000E+96
|
| 85 | decs037 apply 1E+96 -> #47f00000 Clamped
|
| 86 | decs038 apply #47f00000 -> 1.000000E+96
|
| 87 |
|
| 88 | decs051 apply 12345 -> #225049c5
|
| 89 | decs052 apply #225049c5 -> 12345
|
| 90 | decs053 apply 1234 -> #22500534
|
| 91 | decs054 apply #22500534 -> 1234
|
| 92 | decs055 apply 123 -> #225000a3
|
| 93 | decs056 apply #225000a3 -> 123
|
| 94 | decs057 apply 12 -> #22500012
|
| 95 | decs058 apply #22500012 -> 12
|
| 96 | decs059 apply 1 -> #22500001
|
| 97 | decs060 apply #22500001 -> 1
|
| 98 | decs061 apply 1.23 -> #223000a3
|
| 99 | decs062 apply #223000a3 -> 1.23
|
| 100 | decs063 apply 123.45 -> #223049c5
|
| 101 | decs064 apply #223049c5 -> 123.45
|
| 102 |
|
| 103 | -- Nmin and below
|
| 104 | decs071 apply 1E-95 -> #00600001
|
| 105 | decs072 apply #00600001 -> 1E-95
|
| 106 | decs073 apply 1.000000E-95 -> #04000000
|
| 107 | decs074 apply #04000000 -> 1.000000E-95
|
| 108 | decs075 apply 1.000001E-95 -> #04000001
|
| 109 | decs076 apply #04000001 -> 1.000001E-95
|
| 110 |
|
| 111 | decs077 apply 0.100000E-95 -> #00020000 Subnormal
|
| 112 | decs07x apply 1.00000E-96 -> 1.00000E-96 Subnormal
|
| 113 | decs078 apply #00020000 -> 1.00000E-96 Subnormal
|
| 114 | decs079 apply 0.000010E-95 -> #00000010 Subnormal
|
| 115 | decs080 apply #00000010 -> 1.0E-100 Subnormal
|
| 116 | decs081 apply 0.000001E-95 -> #00000001 Subnormal
|
| 117 | decs082 apply #00000001 -> 1E-101 Subnormal
|
| 118 | decs083 apply 1e-101 -> #00000001 Subnormal
|
| 119 | decs084 apply #00000001 -> 1E-101 Subnormal
|
| 120 | decs08x apply 1e-101 -> 1E-101 Subnormal
|
| 121 |
|
| 122 | -- underflows cannot be tested; just check edge case
|
| 123 | decs090 apply 1e-101 -> #00000001 Subnormal
|
| 124 |
|
| 125 | -- same again, negatives --
|
| 126 |
|
| 127 | -- Nmax and similar
|
| 128 | decs122 apply -9.999999E+96 -> #f7f3fcff
|
| 129 | decs123 apply #f7f3fcff -> -9.999999E+96
|
| 130 | decs124 apply -1.234567E+96 -> #c7f4d2e7
|
| 131 | decs125 apply #c7f4d2e7 -> -1.234567E+96
|
| 132 | -- fold-downs (more below)
|
| 133 | decs130 apply -1.23E+96 -> #c7f4c000 Clamped
|
| 134 | decs131 apply #c7f4c000 -> -1.230000E+96
|
| 135 | decs132 apply -1E+96 -> #c7f00000 Clamped
|
| 136 | decs133 apply #c7f00000 -> -1.000000E+96
|
| 137 |
|
| 138 | decs151 apply -12345 -> #a25049c5
|
| 139 | decs152 apply #a25049c5 -> -12345
|
| 140 | decs153 apply -1234 -> #a2500534
|
| 141 | decs154 apply #a2500534 -> -1234
|
| 142 | decs155 apply -123 -> #a25000a3
|
| 143 | decs156 apply #a25000a3 -> -123
|
| 144 | decs157 apply -12 -> #a2500012
|
| 145 | decs158 apply #a2500012 -> -12
|
| 146 | decs159 apply -1 -> #a2500001
|
| 147 | decs160 apply #a2500001 -> -1
|
| 148 | decs161 apply -1.23 -> #a23000a3
|
| 149 | decs162 apply #a23000a3 -> -1.23
|
| 150 | decs163 apply -123.45 -> #a23049c5
|
| 151 | decs164 apply #a23049c5 -> -123.45
|
| 152 |
|
| 153 | -- Nmin and below
|
| 154 | decs171 apply -1E-95 -> #80600001
|
| 155 | decs172 apply #80600001 -> -1E-95
|
| 156 | decs173 apply -1.000000E-95 -> #84000000
|
| 157 | decs174 apply #84000000 -> -1.000000E-95
|
| 158 | decs175 apply -1.000001E-95 -> #84000001
|
| 159 | decs176 apply #84000001 -> -1.000001E-95
|
| 160 |
|
| 161 | decs177 apply -0.100000E-95 -> #80020000 Subnormal
|
| 162 | decs178 apply #80020000 -> -1.00000E-96 Subnormal
|
| 163 | decs179 apply -0.000010E-95 -> #80000010 Subnormal
|
| 164 | decs180 apply #80000010 -> -1.0E-100 Subnormal
|
| 165 | decs181 apply -0.000001E-95 -> #80000001 Subnormal
|
| 166 | decs182 apply #80000001 -> -1E-101 Subnormal
|
| 167 | decs183 apply -1e-101 -> #80000001 Subnormal
|
| 168 | decs184 apply #80000001 -> -1E-101 Subnormal
|
| 169 |
|
| 170 | -- underflow edge case
|
| 171 | decs190 apply -1e-101 -> #80000001 Subnormal
|
| 172 |
|
| 173 | -- zeros
|
| 174 | decs400 apply 0E-400 -> #00000000 Clamped
|
| 175 | decs401 apply 0E-101 -> #00000000
|
| 176 | decs402 apply #00000000 -> 0E-101
|
| 177 | decs403 apply 0.000000E-95 -> #00000000
|
| 178 | decs404 apply #00000000 -> 0E-101
|
| 179 | decs405 apply 0E-2 -> #22300000
|
| 180 | decs406 apply #22300000 -> 0.00
|
| 181 | decs407 apply 0 -> #22500000
|
| 182 | decs408 apply #22500000 -> 0
|
| 183 | decs409 apply 0E+3 -> #22800000
|
| 184 | decs410 apply #22800000 -> 0E+3
|
| 185 | decs411 apply 0E+90 -> #43f00000
|
| 186 | decs412 apply #43f00000 -> 0E+90
|
| 187 | -- clamped zeros...
|
| 188 | decs413 apply 0E+91 -> #43f00000 Clamped
|
| 189 | decs414 apply #43f00000 -> 0E+90
|
| 190 | decs415 apply 0E+96 -> #43f00000 Clamped
|
| 191 | decs416 apply #43f00000 -> 0E+90
|
| 192 | decs417 apply 0E+400 -> #43f00000 Clamped
|
| 193 | decs418 apply #43f00000 -> 0E+90
|
| 194 |
|
| 195 | -- negative zeros
|
| 196 | decs420 apply -0E-400 -> #80000000 Clamped
|
| 197 | decs421 apply -0E-101 -> #80000000
|
| 198 | decs422 apply #80000000 -> -0E-101
|
| 199 | decs423 apply -0.000000E-95 -> #80000000
|
| 200 | decs424 apply #80000000 -> -0E-101
|
| 201 | decs425 apply -0E-2 -> #a2300000
|
| 202 | decs426 apply #a2300000 -> -0.00
|
| 203 | decs427 apply -0 -> #a2500000
|
| 204 | decs428 apply #a2500000 -> -0
|
| 205 | decs429 apply -0E+3 -> #a2800000
|
| 206 | decs430 apply #a2800000 -> -0E+3
|
| 207 | decs431 apply -0E+90 -> #c3f00000
|
| 208 | decs432 apply #c3f00000 -> -0E+90
|
| 209 | -- clamped zeros...
|
| 210 | decs433 apply -0E+91 -> #c3f00000 Clamped
|
| 211 | decs434 apply #c3f00000 -> -0E+90
|
| 212 | decs435 apply -0E+96 -> #c3f00000 Clamped
|
| 213 | decs436 apply #c3f00000 -> -0E+90
|
| 214 | decs437 apply -0E+400 -> #c3f00000 Clamped
|
| 215 | decs438 apply #c3f00000 -> -0E+90
|
| 216 |
|
| 217 | -- Specials
|
| 218 | decs500 apply Infinity -> #78000000
|
| 219 | decs501 apply #78787878 -> #78000000
|
| 220 | decs502 apply #78000000 -> Infinity
|
| 221 | decs503 apply #79797979 -> #78000000
|
| 222 | decs504 apply #79000000 -> Infinity
|
| 223 | decs505 apply #7a7a7a7a -> #78000000
|
| 224 | decs506 apply #7a000000 -> Infinity
|
| 225 | decs507 apply #7b7b7b7b -> #78000000
|
| 226 | decs508 apply #7b000000 -> Infinity
|
| 227 | decs509 apply #7c7c7c7c -> #7c0c7c7c
|
| 228 |
|
| 229 | decs510 apply NaN -> #7c000000
|
| 230 | decs511 apply #7c000000 -> NaN
|
| 231 | decs512 apply #7d7d7d7d -> #7c0d7d7d
|
| 232 | decs513 apply #7d000000 -> NaN
|
| 233 | decs514 apply #7e7e7e7e -> #7e0e7c7e
|
| 234 | decs515 apply #7e000000 -> sNaN
|
| 235 | decs516 apply #7f7f7f7f -> #7e0f7c7f
|
| 236 | decs517 apply #7f000000 -> sNaN
|
| 237 | decs518 apply #7fffffff -> sNaN999999
|
| 238 | decs519 apply #7fffffff -> #7e03fcff
|
| 239 |
|
| 240 | decs520 apply -Infinity -> #f8000000
|
| 241 | decs521 apply #f8787878 -> #f8000000
|
| 242 | decs522 apply #f8000000 -> -Infinity
|
| 243 | decs523 apply #f9797979 -> #f8000000
|
| 244 | decs524 apply #f9000000 -> -Infinity
|
| 245 | decs525 apply #fa7a7a7a -> #f8000000
|
| 246 | decs526 apply #fa000000 -> -Infinity
|
| 247 | decs527 apply #fb7b7b7b -> #f8000000
|
| 248 | decs528 apply #fb000000 -> -Infinity
|
| 249 |
|
| 250 | decs529 apply -NaN -> #fc000000
|
| 251 | decs530 apply #fc7c7c7c -> #fc0c7c7c
|
| 252 | decs531 apply #fc000000 -> -NaN
|
| 253 | decs532 apply #fd7d7d7d -> #fc0d7d7d
|
| 254 | decs533 apply #fd000000 -> -NaN
|
| 255 | decs534 apply #fe7e7e7e -> #fe0e7c7e
|
| 256 | decs535 apply #fe000000 -> -sNaN
|
| 257 | decs536 apply #ff7f7f7f -> #fe0f7c7f
|
| 258 | decs537 apply #ff000000 -> -sNaN
|
| 259 | decs538 apply #ffffffff -> -sNaN999999
|
| 260 | decs539 apply #ffffffff -> #fe03fcff
|
| 261 |
|
| 262 | -- diagnostic NaNs
|
| 263 | decs540 apply NaN -> #7c000000
|
| 264 | decs541 apply NaN0 -> #7c000000
|
| 265 | decs542 apply NaN1 -> #7c000001
|
| 266 | decs543 apply NaN12 -> #7c000012
|
| 267 | decs544 apply NaN79 -> #7c000079
|
| 268 | decs545 apply NaN12345 -> #7c0049c5
|
| 269 | decs546 apply NaN123456 -> #7c028e56
|
| 270 | decs547 apply NaN799799 -> #7c0f7fdf
|
| 271 | decs548 apply NaN999999 -> #7c03fcff
|
| 272 |
|
| 273 |
|
| 274 | -- fold-down full sequence
|
| 275 | decs601 apply 1E+96 -> #47f00000 Clamped
|
| 276 | decs602 apply #47f00000 -> 1.000000E+96
|
| 277 | decs603 apply 1E+95 -> #43f20000 Clamped
|
| 278 | decs604 apply #43f20000 -> 1.00000E+95
|
| 279 | decs605 apply 1E+94 -> #43f04000 Clamped
|
| 280 | decs606 apply #43f04000 -> 1.0000E+94
|
| 281 | decs607 apply 1E+93 -> #43f00400 Clamped
|
| 282 | decs608 apply #43f00400 -> 1.000E+93
|
| 283 | decs609 apply 1E+92 -> #43f00080 Clamped
|
| 284 | decs610 apply #43f00080 -> 1.00E+92
|
| 285 | decs611 apply 1E+91 -> #43f00010 Clamped
|
| 286 | decs612 apply #43f00010 -> 1.0E+91
|
| 287 | decs613 apply 1E+90 -> #43f00001
|
| 288 | decs614 apply #43f00001 -> 1E+90
|
| 289 |
|
| 290 |
|
| 291 | -- Selected DPD codes
|
| 292 | decs700 apply #22500000 -> 0
|
| 293 | decs701 apply #22500009 -> 9
|
| 294 | decs702 apply #22500010 -> 10
|
| 295 | decs703 apply #22500019 -> 19
|
| 296 | decs704 apply #22500020 -> 20
|
| 297 | decs705 apply #22500029 -> 29
|
| 298 | decs706 apply #22500030 -> 30
|
| 299 | decs707 apply #22500039 -> 39
|
| 300 | decs708 apply #22500040 -> 40
|
| 301 | decs709 apply #22500049 -> 49
|
| 302 | decs710 apply #22500050 -> 50
|
| 303 | decs711 apply #22500059 -> 59
|
| 304 | decs712 apply #22500060 -> 60
|
| 305 | decs713 apply #22500069 -> 69
|
| 306 | decs714 apply #22500070 -> 70
|
| 307 | decs715 apply #22500071 -> 71
|
| 308 | decs716 apply #22500072 -> 72
|
| 309 | decs717 apply #22500073 -> 73
|
| 310 | decs718 apply #22500074 -> 74
|
| 311 | decs719 apply #22500075 -> 75
|
| 312 | decs720 apply #22500076 -> 76
|
| 313 | decs721 apply #22500077 -> 77
|
| 314 | decs722 apply #22500078 -> 78
|
| 315 | decs723 apply #22500079 -> 79
|
| 316 |
|
| 317 | decs730 apply #2250029e -> 994
|
| 318 | decs731 apply #2250029f -> 995
|
| 319 | decs732 apply #225002a0 -> 520
|
| 320 | decs733 apply #225002a1 -> 521
|
| 321 |
|
| 322 | -- DPD: one of each of the huffman groups
|
| 323 | decs740 apply #225003f7 -> 777
|
| 324 | decs741 apply #225003f8 -> 778
|
| 325 | decs742 apply #225003eb -> 787
|
| 326 | decs743 apply #2250037d -> 877
|
| 327 | decs744 apply #2250039f -> 997
|
| 328 | decs745 apply #225003bf -> 979
|
| 329 | decs746 apply #225003df -> 799
|
| 330 | decs747 apply #2250006e -> 888
|
| 331 |
|
| 332 |
|
| 333 | -- DPD all-highs cases (includes the 24 redundant codes)
|
| 334 | decs750 apply #2250006e -> 888
|
| 335 | decs751 apply #2250016e -> 888
|
| 336 | decs752 apply #2250026e -> 888
|
| 337 | decs753 apply #2250036e -> 888
|
| 338 | decs754 apply #2250006f -> 889
|
| 339 | decs755 apply #2250016f -> 889
|
| 340 | decs756 apply #2250026f -> 889
|
| 341 | decs757 apply #2250036f -> 889
|
| 342 |
|
| 343 | decs760 apply #2250007e -> 898
|
| 344 | decs761 apply #2250017e -> 898
|
| 345 | decs762 apply #2250027e -> 898
|
| 346 | decs763 apply #2250037e -> 898
|
| 347 | decs764 apply #2250007f -> 899
|
| 348 | decs765 apply #2250017f -> 899
|
| 349 | decs766 apply #2250027f -> 899
|
| 350 | decs767 apply #2250037f -> 899
|
| 351 |
|
| 352 | decs770 apply #225000ee -> 988
|
| 353 | decs771 apply #225001ee -> 988
|
| 354 | decs772 apply #225002ee -> 988
|
| 355 | decs773 apply #225003ee -> 988
|
| 356 | decs774 apply #225000ef -> 989
|
| 357 | decs775 apply #225001ef -> 989
|
| 358 | decs776 apply #225002ef -> 989
|
| 359 | decs777 apply #225003ef -> 989
|
| 360 |
|
| 361 | decs780 apply #225000fe -> 998
|
| 362 | decs781 apply #225001fe -> 998
|
| 363 | decs782 apply #225002fe -> 998
|
| 364 | decs783 apply #225003fe -> 998
|
| 365 | decs784 apply #225000ff -> 999
|
| 366 | decs785 apply #225001ff -> 999
|
| 367 | decs786 apply #225002ff -> 999
|
| 368 | decs787 apply #225003ff -> 999
|
| 369 |
|
Guido van Rossum | 0d3fb8a | 2007-11-26 23:23:18 +0000 | [diff] [blame] | 370 | -- narrowing case
|
| 371 | decs790 apply 2.00E-99 -> #00000100 Subnormal
|
| 372 | decs791 apply #00000100 -> 2.00E-99 Subnormal
|