github.com/cockroachdb/apd/v3@v3.2.0/testdata/tointegralx.decTest (about) 1 ------------------------------------------------------------------------ 2 -- tointegralx.decTest -- round decimal to integral value, exact -- 3 -- Copyright (c) Mike Cowlishaw, 1981, 2010. All rights reserved. -- 4 -- Parts copyright (c) IBM Corporation, 1981, 2008. -- 5 ------------------------------------------------------------------------ 6 -- Please see the document "General Decimal Arithmetic Testcases" -- 7 -- at http://speleotrove.com/decimal for the description of -- 8 -- these testcases. -- 9 -- -- 10 -- These testcases are experimental ('beta' versions), and they -- 11 -- may contain errors. They are offered on an as-is basis. In -- 12 -- particular, achieving the same results as the tests here is not -- 13 -- a guarantee that an implementation complies with any Standard -- 14 -- or specification. The tests are not exhaustive. -- 15 -- -- 16 -- Please send comments, suggestions, and corrections to the author: -- 17 -- Mike Cowlishaw, mfc@speleotrove.com -- 18 ------------------------------------------------------------------------ 19 version: 2.62 20 21 -- This set of tests tests the extended specification 'round-to-integral 22 -- value' operation (from IEEE 854, later modified in 754r). 23 -- All non-zero results are defined as being those from either copy or 24 -- quantize, so those are assumed to have been tested. 25 26 -- This tests toIntegraExact, which may set Inexact 27 28 extended: 1 29 precision: 9 30 rounding: half_up 31 maxExponent: 999 32 minExponent: -999 33 34 intxx001 tointegralx 0 -> 0 35 intxx002 tointegralx 0.0 -> 0 36 intxx003 tointegralx 0.1 -> 0 Inexact Rounded 37 intxx004 tointegralx 0.2 -> 0 Inexact Rounded 38 intxx005 tointegralx 0.3 -> 0 Inexact Rounded 39 intxx006 tointegralx 0.4 -> 0 Inexact Rounded 40 intxx007 tointegralx 0.5 -> 1 Inexact Rounded 41 intxx008 tointegralx 0.6 -> 1 Inexact Rounded 42 intxx009 tointegralx 0.7 -> 1 Inexact Rounded 43 intxx010 tointegralx 0.8 -> 1 Inexact Rounded 44 intxx011 tointegralx 0.9 -> 1 Inexact Rounded 45 intxx012 tointegralx 1 -> 1 46 intxx013 tointegralx 1.0 -> 1 Rounded 47 intxx014 tointegralx 1.1 -> 1 Inexact Rounded 48 intxx015 tointegralx 1.2 -> 1 Inexact Rounded 49 intxx016 tointegralx 1.3 -> 1 Inexact Rounded 50 intxx017 tointegralx 1.4 -> 1 Inexact Rounded 51 intxx018 tointegralx 1.5 -> 2 Inexact Rounded 52 intxx019 tointegralx 1.6 -> 2 Inexact Rounded 53 intxx020 tointegralx 1.7 -> 2 Inexact Rounded 54 intxx021 tointegralx 1.8 -> 2 Inexact Rounded 55 intxx022 tointegralx 1.9 -> 2 Inexact Rounded 56 -- negatives 57 intxx031 tointegralx -0 -> -0 58 intxx032 tointegralx -0.0 -> -0 59 intxx033 tointegralx -0.1 -> -0 Inexact Rounded 60 intxx034 tointegralx -0.2 -> -0 Inexact Rounded 61 intxx035 tointegralx -0.3 -> -0 Inexact Rounded 62 intxx036 tointegralx -0.4 -> -0 Inexact Rounded 63 intxx037 tointegralx -0.5 -> -1 Inexact Rounded 64 intxx038 tointegralx -0.6 -> -1 Inexact Rounded 65 intxx039 tointegralx -0.7 -> -1 Inexact Rounded 66 intxx040 tointegralx -0.8 -> -1 Inexact Rounded 67 intxx041 tointegralx -0.9 -> -1 Inexact Rounded 68 intxx042 tointegralx -1 -> -1 69 intxx043 tointegralx -1.0 -> -1 Rounded 70 intxx044 tointegralx -1.1 -> -1 Inexact Rounded 71 intxx045 tointegralx -1.2 -> -1 Inexact Rounded 72 intxx046 tointegralx -1.3 -> -1 Inexact Rounded 73 intxx047 tointegralx -1.4 -> -1 Inexact Rounded 74 intxx048 tointegralx -1.5 -> -2 Inexact Rounded 75 intxx049 tointegralx -1.6 -> -2 Inexact Rounded 76 intxx050 tointegralx -1.7 -> -2 Inexact Rounded 77 intxx051 tointegralx -1.8 -> -2 Inexact Rounded 78 intxx052 tointegralx -1.9 -> -2 Inexact Rounded 79 -- next two would be NaN using quantize(x, 0) 80 intxx053 tointegralx 10E+30 -> 1.0E+31 81 intxx054 tointegralx -10E+30 -> -1.0E+31 82 83 -- numbers around precision 84 precision: 9 85 intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded 86 intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded 87 intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded 88 intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded 89 intxx065 tointegralx '56267E-0' -> '56267' 90 intxx066 tointegralx '56267E+0' -> '56267' 91 intxx067 tointegralx '56267E+1' -> '5.6267E+5' 92 intxx068 tointegralx '56267E+2' -> '5.6267E+6' 93 intxx069 tointegralx '56267E+3' -> '5.6267E+7' 94 intxx070 tointegralx '56267E+4' -> '5.6267E+8' 95 intxx071 tointegralx '56267E+5' -> '5.6267E+9' 96 intxx072 tointegralx '56267E+6' -> '5.6267E+10' 97 intxx073 tointegralx '1.23E+96' -> '1.23E+96' 98 intxx074 tointegralx '1.23E+384' -> '1.23E+384' 99 intxx075 tointegralx '1.23E+999' -> '1.23E+999' 100 101 intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded 102 intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded 103 intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded 104 intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded 105 intxx085 tointegralx '-56267E-0' -> '-56267' 106 intxx086 tointegralx '-56267E+0' -> '-56267' 107 intxx087 tointegralx '-56267E+1' -> '-5.6267E+5' 108 intxx088 tointegralx '-56267E+2' -> '-5.6267E+6' 109 intxx089 tointegralx '-56267E+3' -> '-5.6267E+7' 110 intxx090 tointegralx '-56267E+4' -> '-5.6267E+8' 111 intxx091 tointegralx '-56267E+5' -> '-5.6267E+9' 112 intxx092 tointegralx '-56267E+6' -> '-5.6267E+10' 113 intxx093 tointegralx '-1.23E+96' -> '-1.23E+96' 114 intxx094 tointegralx '-1.23E+384' -> '-1.23E+384' 115 intxx095 tointegralx '-1.23E+999' -> '-1.23E+999' 116 117 -- subnormal inputs 118 intxx100 tointegralx 1E-999 -> 0 Inexact Rounded 119 intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded 120 intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded 121 intxx103 tointegralx 0E-999 -> 0 122 123 -- specials and zeros 124 intxx120 tointegralx 'Inf' -> Infinity 125 intxx121 tointegralx '-Inf' -> -Infinity 126 intxx122 tointegralx NaN -> NaN 127 intxx123 tointegralx sNaN -> NaN Invalid_operation 128 intxx124 tointegralx 0 -> 0 129 intxx125 tointegralx -0 -> -0 130 intxx126 tointegralx 0.000 -> 0 131 intxx127 tointegralx 0.00 -> 0 132 intxx128 tointegralx 0.0 -> 0 133 intxx129 tointegralx 0 -> 0 134 intxx130 tointegralx 0E-3 -> 0 135 intxx131 tointegralx 0E-2 -> 0 136 intxx132 tointegralx 0E-1 -> 0 137 intxx133 tointegralx 0E-0 -> 0 138 intxx134 tointegralx 0E+1 -> 0E+1 139 intxx135 tointegralx 0E+2 -> 0E+2 140 intxx136 tointegralx 0E+3 -> 0E+3 141 intxx137 tointegralx 0E+4 -> 0E+4 142 intxx138 tointegralx 0E+5 -> 0E+5 143 intxx139 tointegralx -0.000 -> -0 144 intxx140 tointegralx -0.00 -> -0 145 intxx141 tointegralx -0.0 -> -0 146 intxx142 tointegralx -0 -> -0 147 intxx143 tointegralx -0E-3 -> -0 148 intxx144 tointegralx -0E-2 -> -0 149 intxx145 tointegralx -0E-1 -> -0 150 intxx146 tointegralx -0E-0 -> -0 151 intxx147 tointegralx -0E+1 -> -0E+1 152 intxx148 tointegralx -0E+2 -> -0E+2 153 intxx149 tointegralx -0E+3 -> -0E+3 154 intxx150 tointegralx -0E+4 -> -0E+4 155 intxx151 tointegralx -0E+5 -> -0E+5 156 -- propagating NaNs 157 intxx152 tointegralx NaN808 -> NaN808 158 intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation 159 intxx154 tointegralx -NaN808 -> -NaN808 160 intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation 161 intxx156 tointegralx -NaN -> -NaN 162 intxx157 tointegralx -sNaN -> -NaN Invalid_operation 163 164 -- examples 165 rounding: half_up 166 precision: 9 167 intxx200 tointegralx 2.1 -> 2 Inexact Rounded 168 intxx201 tointegralx 100 -> 100 169 intxx202 tointegralx 100.0 -> 100 Rounded 170 intxx203 tointegralx 101.5 -> 102 Inexact Rounded 171 intxx204 tointegralx -101.5 -> -102 Inexact Rounded 172 intxx205 tointegralx 10E+5 -> 1.0E+6 173 intxx206 tointegralx 7.89E+77 -> 7.89E+77 174 intxx207 tointegralx -Inf -> -Infinity 175 176 177 -- all rounding modes 178 rounding: half_even 179 180 intxx210 tointegralx 55.5 -> 56 Inexact Rounded 181 intxx211 tointegralx 56.5 -> 56 Inexact Rounded 182 intxx212 tointegralx 57.5 -> 58 Inexact Rounded 183 intxx213 tointegralx -55.5 -> -56 Inexact Rounded 184 intxx214 tointegralx -56.5 -> -56 Inexact Rounded 185 intxx215 tointegralx -57.5 -> -58 Inexact Rounded 186 187 rounding: half_up 188 189 intxx220 tointegralx 55.5 -> 56 Inexact Rounded 190 intxx221 tointegralx 56.5 -> 57 Inexact Rounded 191 intxx222 tointegralx 57.5 -> 58 Inexact Rounded 192 intxx223 tointegralx -55.5 -> -56 Inexact Rounded 193 intxx224 tointegralx -56.5 -> -57 Inexact Rounded 194 intxx225 tointegralx -57.5 -> -58 Inexact Rounded 195 196 rounding: half_down 197 198 intxx230 tointegralx 55.5 -> 55 Inexact Rounded 199 intxx231 tointegralx 56.5 -> 56 Inexact Rounded 200 intxx232 tointegralx 57.5 -> 57 Inexact Rounded 201 intxx233 tointegralx -55.5 -> -55 Inexact Rounded 202 intxx234 tointegralx -56.5 -> -56 Inexact Rounded 203 intxx235 tointegralx -57.5 -> -57 Inexact Rounded 204 205 rounding: up 206 207 intxx240 tointegralx 55.3 -> 56 Inexact Rounded 208 intxx241 tointegralx 56.3 -> 57 Inexact Rounded 209 intxx242 tointegralx 57.3 -> 58 Inexact Rounded 210 intxx243 tointegralx -55.3 -> -56 Inexact Rounded 211 intxx244 tointegralx -56.3 -> -57 Inexact Rounded 212 intxx245 tointegralx -57.3 -> -58 Inexact Rounded 213 214 rounding: down 215 216 intxx250 tointegralx 55.7 -> 55 Inexact Rounded 217 intxx251 tointegralx 56.7 -> 56 Inexact Rounded 218 intxx252 tointegralx 57.7 -> 57 Inexact Rounded 219 intxx253 tointegralx -55.7 -> -55 Inexact Rounded 220 intxx254 tointegralx -56.7 -> -56 Inexact Rounded 221 intxx255 tointegralx -57.7 -> -57 Inexact Rounded 222 223 rounding: ceiling 224 225 intxx260 tointegralx 55.3 -> 56 Inexact Rounded 226 intxx261 tointegralx 56.3 -> 57 Inexact Rounded 227 intxx262 tointegralx 57.3 -> 58 Inexact Rounded 228 intxx263 tointegralx -55.3 -> -55 Inexact Rounded 229 intxx264 tointegralx -56.3 -> -56 Inexact Rounded 230 intxx265 tointegralx -57.3 -> -57 Inexact Rounded 231 232 rounding: floor 233 234 intxx270 tointegralx 55.7 -> 55 Inexact Rounded 235 intxx271 tointegralx 56.7 -> 56 Inexact Rounded 236 intxx272 tointegralx 57.7 -> 57 Inexact Rounded 237 intxx273 tointegralx -55.7 -> -56 Inexact Rounded 238 intxx274 tointegralx -56.7 -> -57 Inexact Rounded 239 intxx275 tointegralx -57.7 -> -58 Inexact Rounded 240 241 -- Int and uInt32 edge values for testing conversions 242 precision: 16 243 intxx300 tointegralx -2147483646 -> -2147483646 244 intxx301 tointegralx -2147483647 -> -2147483647 245 intxx302 tointegralx -2147483648 -> -2147483648 246 intxx303 tointegralx -2147483649 -> -2147483649 247 intxx304 tointegralx 2147483646 -> 2147483646 248 intxx305 tointegralx 2147483647 -> 2147483647 249 intxx306 tointegralx 2147483648 -> 2147483648 250 intxx307 tointegralx 2147483649 -> 2147483649 251 intxx308 tointegralx 4294967294 -> 4294967294 252 intxx309 tointegralx 4294967295 -> 4294967295 253 intxx310 tointegralx 4294967296 -> 4294967296 254 intxx311 tointegralx 4294967297 -> 4294967297