Thomas Wouters | 1b7f891 | 2007-09-19 03:06:30 +0000 | [diff] [blame] | 1 | ------------------------------------------------------------------------
|
| 2 | -- ddToIntegral.decTest -- round Double to integral value --
|
Benjamin Peterson | f17ff4e | 2008-07-31 16:32:12 +0000 | [diff] [blame] | 3 | -- Copyright (c) IBM Corporation, 2001, 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 | ------------------------------------------------------------------------
|
Mark Dickinson | 8a54653 | 2009-10-08 16:30:38 +0000 | [diff] [blame] | 20 | version: 2.59
|
Thomas Wouters | 1b7f891 | 2007-09-19 03:06:30 +0000 | [diff] [blame] | 21 |
|
| 22 | -- This set of tests tests the extended specification 'round-to-integral
|
| 23 | -- value-exact' operations (from IEEE 854, later modified in 754r).
|
| 24 | -- All non-zero results are defined as being those from either copy or
|
| 25 | -- quantize, so those are assumed to have been tested extensively
|
| 26 | -- elsewhere; the tests here are for integrity, rounding mode, etc.
|
| 27 | -- Also, it is assumed the test harness will use these tests for both
|
| 28 | -- ToIntegralExact (which does set Inexact) and the fixed-name
|
| 29 | -- functions (which do not set Inexact).
|
| 30 |
|
| 31 | -- Note that decNumber implements an earlier definition of toIntegral
|
| 32 | -- which never sets Inexact; the decTest operator for that is called
|
| 33 | -- 'tointegral' instead of 'tointegralx'.
|
| 34 |
|
| 35 | precision: 16
|
| 36 | maxExponent: 384
|
| 37 | minExponent: -383
|
| 38 | extended: 1
|
| 39 | clamp: 1
|
| 40 | rounding: half_even
|
| 41 |
|
| 42 | ddintx001 tointegralx 0 -> 0
|
| 43 | ddintx002 tointegralx 0.0 -> 0
|
| 44 | ddintx003 tointegralx 0.1 -> 0 Inexact Rounded
|
| 45 | ddintx004 tointegralx 0.2 -> 0 Inexact Rounded
|
| 46 | ddintx005 tointegralx 0.3 -> 0 Inexact Rounded
|
| 47 | ddintx006 tointegralx 0.4 -> 0 Inexact Rounded
|
| 48 | ddintx007 tointegralx 0.5 -> 0 Inexact Rounded
|
| 49 | ddintx008 tointegralx 0.6 -> 1 Inexact Rounded
|
| 50 | ddintx009 tointegralx 0.7 -> 1 Inexact Rounded
|
| 51 | ddintx010 tointegralx 0.8 -> 1 Inexact Rounded
|
| 52 | ddintx011 tointegralx 0.9 -> 1 Inexact Rounded
|
| 53 | ddintx012 tointegralx 1 -> 1
|
| 54 | ddintx013 tointegralx 1.0 -> 1 Rounded
|
| 55 | ddintx014 tointegralx 1.1 -> 1 Inexact Rounded
|
| 56 | ddintx015 tointegralx 1.2 -> 1 Inexact Rounded
|
| 57 | ddintx016 tointegralx 1.3 -> 1 Inexact Rounded
|
| 58 | ddintx017 tointegralx 1.4 -> 1 Inexact Rounded
|
| 59 | ddintx018 tointegralx 1.5 -> 2 Inexact Rounded
|
| 60 | ddintx019 tointegralx 1.6 -> 2 Inexact Rounded
|
| 61 | ddintx020 tointegralx 1.7 -> 2 Inexact Rounded
|
| 62 | ddintx021 tointegralx 1.8 -> 2 Inexact Rounded
|
| 63 | ddintx022 tointegralx 1.9 -> 2 Inexact Rounded
|
| 64 | -- negatives
|
| 65 | ddintx031 tointegralx -0 -> -0
|
| 66 | ddintx032 tointegralx -0.0 -> -0
|
| 67 | ddintx033 tointegralx -0.1 -> -0 Inexact Rounded
|
| 68 | ddintx034 tointegralx -0.2 -> -0 Inexact Rounded
|
| 69 | ddintx035 tointegralx -0.3 -> -0 Inexact Rounded
|
| 70 | ddintx036 tointegralx -0.4 -> -0 Inexact Rounded
|
| 71 | ddintx037 tointegralx -0.5 -> -0 Inexact Rounded
|
| 72 | ddintx038 tointegralx -0.6 -> -1 Inexact Rounded
|
| 73 | ddintx039 tointegralx -0.7 -> -1 Inexact Rounded
|
| 74 | ddintx040 tointegralx -0.8 -> -1 Inexact Rounded
|
| 75 | ddintx041 tointegralx -0.9 -> -1 Inexact Rounded
|
| 76 | ddintx042 tointegralx -1 -> -1
|
| 77 | ddintx043 tointegralx -1.0 -> -1 Rounded
|
| 78 | ddintx044 tointegralx -1.1 -> -1 Inexact Rounded
|
| 79 | ddintx045 tointegralx -1.2 -> -1 Inexact Rounded
|
| 80 | ddintx046 tointegralx -1.3 -> -1 Inexact Rounded
|
| 81 | ddintx047 tointegralx -1.4 -> -1 Inexact Rounded
|
| 82 | ddintx048 tointegralx -1.5 -> -2 Inexact Rounded
|
| 83 | ddintx049 tointegralx -1.6 -> -2 Inexact Rounded
|
| 84 | ddintx050 tointegralx -1.7 -> -2 Inexact Rounded
|
| 85 | ddintx051 tointegralx -1.8 -> -2 Inexact Rounded
|
| 86 | ddintx052 tointegralx -1.9 -> -2 Inexact Rounded
|
| 87 | -- next two would be NaN using quantize(x, 0)
|
| 88 | ddintx053 tointegralx 10E+60 -> 1.0E+61
|
| 89 | ddintx054 tointegralx -10E+60 -> -1.0E+61
|
| 90 |
|
| 91 | -- numbers around precision
|
| 92 | ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
|
| 93 | ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
|
| 94 | ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
|
| 95 | ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
|
| 96 | ddintx065 tointegralx '56267E-0' -> '56267'
|
| 97 | ddintx066 tointegralx '56267E+0' -> '56267'
|
| 98 | ddintx067 tointegralx '56267E+1' -> '5.6267E+5'
|
| 99 | ddintx068 tointegralx '56267E+9' -> '5.6267E+13'
|
| 100 | ddintx069 tointegralx '56267E+10' -> '5.6267E+14'
|
| 101 | ddintx070 tointegralx '56267E+11' -> '5.6267E+15'
|
| 102 | ddintx071 tointegralx '56267E+12' -> '5.6267E+16'
|
| 103 | ddintx072 tointegralx '56267E+13' -> '5.6267E+17'
|
| 104 | ddintx073 tointegralx '1.23E+96' -> '1.23E+96'
|
| 105 | ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped
|
| 106 |
|
| 107 | ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
|
| 108 | ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
|
| 109 | ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
|
| 110 | ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
|
| 111 | ddintx085 tointegralx '-56267E-0' -> '-56267'
|
| 112 | ddintx086 tointegralx '-56267E+0' -> '-56267'
|
| 113 | ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
|
| 114 | ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
|
| 115 | ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
|
| 116 | ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
|
| 117 | ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
|
| 118 | ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
|
| 119 | ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
|
| 120 | ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped
|
| 121 |
|
| 122 | -- subnormal inputs
|
| 123 | ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded
|
| 124 | ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
|
| 125 | ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
|
| 126 | ddintx103 tointegralx 0E-299 -> 0
|
| 127 |
|
| 128 | -- specials and zeros
|
| 129 | ddintx120 tointegralx 'Inf' -> Infinity
|
| 130 | ddintx121 tointegralx '-Inf' -> -Infinity
|
| 131 | ddintx122 tointegralx NaN -> NaN
|
| 132 | ddintx123 tointegralx sNaN -> NaN Invalid_operation
|
| 133 | ddintx124 tointegralx 0 -> 0
|
| 134 | ddintx125 tointegralx -0 -> -0
|
| 135 | ddintx126 tointegralx 0.000 -> 0
|
| 136 | ddintx127 tointegralx 0.00 -> 0
|
| 137 | ddintx128 tointegralx 0.0 -> 0
|
| 138 | ddintx129 tointegralx 0 -> 0
|
| 139 | ddintx130 tointegralx 0E-3 -> 0
|
| 140 | ddintx131 tointegralx 0E-2 -> 0
|
| 141 | ddintx132 tointegralx 0E-1 -> 0
|
| 142 | ddintx133 tointegralx 0E-0 -> 0
|
| 143 | ddintx134 tointegralx 0E+1 -> 0E+1
|
| 144 | ddintx135 tointegralx 0E+2 -> 0E+2
|
| 145 | ddintx136 tointegralx 0E+3 -> 0E+3
|
| 146 | ddintx137 tointegralx 0E+4 -> 0E+4
|
| 147 | ddintx138 tointegralx 0E+5 -> 0E+5
|
| 148 | ddintx139 tointegralx -0.000 -> -0
|
| 149 | ddintx140 tointegralx -0.00 -> -0
|
| 150 | ddintx141 tointegralx -0.0 -> -0
|
| 151 | ddintx142 tointegralx -0 -> -0
|
| 152 | ddintx143 tointegralx -0E-3 -> -0
|
| 153 | ddintx144 tointegralx -0E-2 -> -0
|
| 154 | ddintx145 tointegralx -0E-1 -> -0
|
| 155 | ddintx146 tointegralx -0E-0 -> -0
|
| 156 | ddintx147 tointegralx -0E+1 -> -0E+1
|
| 157 | ddintx148 tointegralx -0E+2 -> -0E+2
|
| 158 | ddintx149 tointegralx -0E+3 -> -0E+3
|
| 159 | ddintx150 tointegralx -0E+4 -> -0E+4
|
| 160 | ddintx151 tointegralx -0E+5 -> -0E+5
|
| 161 | -- propagating NaNs
|
| 162 | ddintx152 tointegralx NaN808 -> NaN808
|
| 163 | ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
|
| 164 | ddintx154 tointegralx -NaN808 -> -NaN808
|
| 165 | ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
|
| 166 | ddintx156 tointegralx -NaN -> -NaN
|
| 167 | ddintx157 tointegralx -sNaN -> -NaN Invalid_operation
|
| 168 |
|
| 169 | -- examples
|
| 170 | rounding: half_up
|
| 171 | ddintx200 tointegralx 2.1 -> 2 Inexact Rounded
|
| 172 | ddintx201 tointegralx 100 -> 100
|
| 173 | ddintx202 tointegralx 100.0 -> 100 Rounded
|
| 174 | ddintx203 tointegralx 101.5 -> 102 Inexact Rounded
|
| 175 | ddintx204 tointegralx -101.5 -> -102 Inexact Rounded
|
| 176 | ddintx205 tointegralx 10E+5 -> 1.0E+6
|
| 177 | ddintx206 tointegralx 7.89E+77 -> 7.89E+77
|
| 178 | ddintx207 tointegralx -Inf -> -Infinity
|
| 179 |
|
| 180 |
|
| 181 | -- all rounding modes
|
| 182 | rounding: half_even
|
| 183 | ddintx210 tointegralx 55.5 -> 56 Inexact Rounded
|
| 184 | ddintx211 tointegralx 56.5 -> 56 Inexact Rounded
|
| 185 | ddintx212 tointegralx 57.5 -> 58 Inexact Rounded
|
| 186 | ddintx213 tointegralx -55.5 -> -56 Inexact Rounded
|
| 187 | ddintx214 tointegralx -56.5 -> -56 Inexact Rounded
|
| 188 | ddintx215 tointegralx -57.5 -> -58 Inexact Rounded
|
| 189 |
|
| 190 | rounding: half_up
|
| 191 |
|
| 192 | ddintx220 tointegralx 55.5 -> 56 Inexact Rounded
|
| 193 | ddintx221 tointegralx 56.5 -> 57 Inexact Rounded
|
| 194 | ddintx222 tointegralx 57.5 -> 58 Inexact Rounded
|
| 195 | ddintx223 tointegralx -55.5 -> -56 Inexact Rounded
|
| 196 | ddintx224 tointegralx -56.5 -> -57 Inexact Rounded
|
| 197 | ddintx225 tointegralx -57.5 -> -58 Inexact Rounded
|
| 198 |
|
| 199 | rounding: half_down
|
| 200 |
|
| 201 | ddintx230 tointegralx 55.5 -> 55 Inexact Rounded
|
| 202 | ddintx231 tointegralx 56.5 -> 56 Inexact Rounded
|
| 203 | ddintx232 tointegralx 57.5 -> 57 Inexact Rounded
|
| 204 | ddintx233 tointegralx -55.5 -> -55 Inexact Rounded
|
| 205 | ddintx234 tointegralx -56.5 -> -56 Inexact Rounded
|
| 206 | ddintx235 tointegralx -57.5 -> -57 Inexact Rounded
|
| 207 |
|
| 208 | rounding: up
|
| 209 |
|
| 210 | ddintx240 tointegralx 55.3 -> 56 Inexact Rounded
|
| 211 | ddintx241 tointegralx 56.3 -> 57 Inexact Rounded
|
| 212 | ddintx242 tointegralx 57.3 -> 58 Inexact Rounded
|
| 213 | ddintx243 tointegralx -55.3 -> -56 Inexact Rounded
|
| 214 | ddintx244 tointegralx -56.3 -> -57 Inexact Rounded
|
| 215 | ddintx245 tointegralx -57.3 -> -58 Inexact Rounded
|
| 216 |
|
| 217 | rounding: down
|
| 218 |
|
| 219 | ddintx250 tointegralx 55.7 -> 55 Inexact Rounded
|
| 220 | ddintx251 tointegralx 56.7 -> 56 Inexact Rounded
|
| 221 | ddintx252 tointegralx 57.7 -> 57 Inexact Rounded
|
| 222 | ddintx253 tointegralx -55.7 -> -55 Inexact Rounded
|
| 223 | ddintx254 tointegralx -56.7 -> -56 Inexact Rounded
|
| 224 | ddintx255 tointegralx -57.7 -> -57 Inexact Rounded
|
| 225 |
|
| 226 | rounding: ceiling
|
| 227 |
|
| 228 | ddintx260 tointegralx 55.3 -> 56 Inexact Rounded
|
| 229 | ddintx261 tointegralx 56.3 -> 57 Inexact Rounded
|
| 230 | ddintx262 tointegralx 57.3 -> 58 Inexact Rounded
|
| 231 | ddintx263 tointegralx -55.3 -> -55 Inexact Rounded
|
| 232 | ddintx264 tointegralx -56.3 -> -56 Inexact Rounded
|
| 233 | ddintx265 tointegralx -57.3 -> -57 Inexact Rounded
|
| 234 |
|
| 235 | rounding: floor
|
| 236 |
|
| 237 | ddintx270 tointegralx 55.7 -> 55 Inexact Rounded
|
| 238 | ddintx271 tointegralx 56.7 -> 56 Inexact Rounded
|
| 239 | ddintx272 tointegralx 57.7 -> 57 Inexact Rounded
|
| 240 | ddintx273 tointegralx -55.7 -> -56 Inexact Rounded
|
| 241 | ddintx274 tointegralx -56.7 -> -57 Inexact Rounded
|
| 242 | ddintx275 tointegralx -57.7 -> -58 Inexact Rounded
|
| 243 |
|
| 244 | -- Int and uInt32 edge values for testing conversions
|
| 245 | ddintx300 tointegralx -2147483646 -> -2147483646
|
| 246 | ddintx301 tointegralx -2147483647 -> -2147483647
|
| 247 | ddintx302 tointegralx -2147483648 -> -2147483648
|
| 248 | ddintx303 tointegralx -2147483649 -> -2147483649
|
| 249 | ddintx304 tointegralx 2147483646 -> 2147483646
|
| 250 | ddintx305 tointegralx 2147483647 -> 2147483647
|
| 251 | ddintx306 tointegralx 2147483648 -> 2147483648
|
| 252 | ddintx307 tointegralx 2147483649 -> 2147483649
|
| 253 | ddintx308 tointegralx 4294967294 -> 4294967294
|
| 254 | ddintx309 tointegralx 4294967295 -> 4294967295
|
| 255 | ddintx310 tointegralx 4294967296 -> 4294967296
|
| 256 | ddintx311 tointegralx 4294967297 -> 4294967297
|
| 257 |
|