github.com/cockroachdb/apd/v3@v3.2.0/testdata/plus.decTest (about) 1 ------------------------------------------------------------------------ 2 -- plus.decTest -- decimal monadic addition -- 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 primarily tests the existence of the operator. 22 -- Addition and rounding, and most overflows, are tested elsewhere. 23 24 extended: 1 25 precision: 9 26 rounding: half_up 27 maxExponent: 384 28 minexponent: -383 29 30 plux001 plus '1' -> '1' 31 plux002 plus '-1' -> '-1' 32 plux003 plus '1.00' -> '1.00' 33 plux004 plus '-1.00' -> '-1.00' 34 plux005 plus '0' -> '0' 35 plux006 plus '0.00' -> '0.00' 36 plux007 plus '00.0' -> '0.0' 37 plux008 plus '00.00' -> '0.00' 38 plux009 plus '00' -> '0' 39 40 plux010 plus '-2' -> '-2' 41 plux011 plus '2' -> '2' 42 plux012 plus '-2.00' -> '-2.00' 43 plux013 plus '2.00' -> '2.00' 44 plux014 plus '-0' -> '0' 45 plux015 plus '-0.00' -> '0.00' 46 plux016 plus '-00.0' -> '0.0' 47 plux017 plus '-00.00' -> '0.00' 48 plux018 plus '-00' -> '0' 49 50 plux020 plus '-2000000' -> '-2000000' 51 plux021 plus '2000000' -> '2000000' 52 precision: 7 53 plux022 plus '-2000000' -> '-2000000' 54 plux023 plus '2000000' -> '2000000' 55 precision: 6 56 plux024 plus '-2000000' -> '-2.00000E+6' Rounded 57 plux025 plus '2000000' -> '2.00000E+6' Rounded 58 precision: 3 59 plux026 plus '-2000000' -> '-2.00E+6' Rounded 60 plux027 plus '2000000' -> '2.00E+6' Rounded 61 62 -- more fixed, potential LHS swaps if done by add 0 63 precision: 9 64 plux060 plus '56267E-10' -> '0.0000056267' 65 plux061 plus '56267E-5' -> '0.56267' 66 plux062 plus '56267E-2' -> '562.67' 67 plux063 plus '56267E-1' -> '5626.7' 68 plux065 plus '56267E-0' -> '56267' 69 plux066 plus '56267E+0' -> '56267' 70 plux067 plus '56267E+1' -> '5.6267E+5' 71 plux068 plus '56267E+2' -> '5.6267E+6' 72 plux069 plus '56267E+3' -> '5.6267E+7' 73 plux070 plus '56267E+4' -> '5.6267E+8' 74 plux071 plus '56267E+5' -> '5.6267E+9' 75 plux072 plus '56267E+6' -> '5.6267E+10' 76 plux080 plus '-56267E-10' -> '-0.0000056267' 77 plux081 plus '-56267E-5' -> '-0.56267' 78 plux082 plus '-56267E-2' -> '-562.67' 79 plux083 plus '-56267E-1' -> '-5626.7' 80 plux085 plus '-56267E-0' -> '-56267' 81 plux086 plus '-56267E+0' -> '-56267' 82 plux087 plus '-56267E+1' -> '-5.6267E+5' 83 plux088 plus '-56267E+2' -> '-5.6267E+6' 84 plux089 plus '-56267E+3' -> '-5.6267E+7' 85 plux090 plus '-56267E+4' -> '-5.6267E+8' 86 plux091 plus '-56267E+5' -> '-5.6267E+9' 87 plux092 plus '-56267E+6' -> '-5.6267E+10' 88 89 -- "lhs" zeros in plus and minus have exponent = operand 90 plux120 plus '-0E3' -> '0E+3' 91 plux121 plus '-0E2' -> '0E+2' 92 plux122 plus '-0E1' -> '0E+1' 93 plux123 plus '-0E0' -> '0' 94 plux124 plus '+0E0' -> '0' 95 plux125 plus '+0E1' -> '0E+1' 96 plux126 plus '+0E2' -> '0E+2' 97 plux127 plus '+0E3' -> '0E+3' 98 99 plux130 plus '-5E3' -> '-5E+3' 100 plux131 plus '-5E8' -> '-5E+8' 101 plux132 plus '-5E13' -> '-5E+13' 102 plux133 plus '-5E18' -> '-5E+18' 103 plux134 plus '+5E3' -> '5E+3' 104 plux135 plus '+5E8' -> '5E+8' 105 plux136 plus '+5E13' -> '5E+13' 106 plux137 plus '+5E18' -> '5E+18' 107 108 -- specials 109 plux150 plus 'Inf' -> 'Infinity' 110 plux151 plus '-Inf' -> '-Infinity' 111 plux152 plus NaN -> NaN 112 plux153 plus sNaN -> NaN Invalid_operation 113 plux154 plus NaN77 -> NaN77 114 plux155 plus sNaN88 -> NaN88 Invalid_operation 115 plux156 plus -NaN -> -NaN 116 plux157 plus -sNaN -> -NaN Invalid_operation 117 plux158 plus -NaN77 -> -NaN77 118 plux159 plus -sNaN88 -> -NaN88 Invalid_operation 119 120 -- overflow tests 121 maxexponent: 999999999 122 minexponent: -999999999 123 precision: 3 124 plux160 plus 9.999E+999999999 -> Infinity Inexact Overflow Rounded 125 plux161 plus -9.999E+999999999 -> -Infinity Inexact Overflow Rounded 126 127 -- subnormals and underflow 128 precision: 3 129 maxexponent: 999 130 minexponent: -999 131 plux210 plus 1.00E-999 -> 1.00E-999 132 plux211 plus 0.1E-999 -> 1E-1000 Subnormal 133 plux212 plus 0.10E-999 -> 1.0E-1000 Subnormal 134 plux213 plus 0.100E-999 -> 1.0E-1000 Subnormal Rounded 135 plux214 plus 0.01E-999 -> 1E-1001 Subnormal 136 -- next is rounded to Emin 137 plux215 plus 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow 138 plux216 plus 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow 139 plux217 plus 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow 140 plux218 plus 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 141 plux219 plus 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 142 plux220 plus 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 143 144 plux230 plus -1.00E-999 -> -1.00E-999 145 plux231 plus -0.1E-999 -> -1E-1000 Subnormal 146 plux232 plus -0.10E-999 -> -1.0E-1000 Subnormal 147 plux233 plus -0.100E-999 -> -1.0E-1000 Subnormal Rounded 148 plux234 plus -0.01E-999 -> -1E-1001 Subnormal 149 -- next is rounded to Emin 150 plux235 plus -0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow 151 plux236 plus -0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow 152 plux237 plus -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow 153 plux238 plus -0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 154 plux239 plus -0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 155 plux240 plus -0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 156 157 -- subnormals clamped to 0-Etiny 158 precision: 16 159 maxExponent: 384 160 minExponent: -383 161 plux251 plus 7E-398 -> 7E-398 Subnormal 162 plux252 plus 0E-398 -> 0E-398 163 plux253 plus 7E-399 -> 1E-398 Subnormal Underflow Inexact Rounded 164 plux254 plus 4E-399 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded 165 plux255 plus 7E-400 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded 166 plux256 plus 7E-401 -> 0E-398 Clamped Subnormal Underflow Inexact Rounded 167 plux257 plus 0E-399 -> 0E-398 Clamped 168 plux258 plus 0E-400 -> 0E-398 Clamped 169 plux259 plus 0E-401 -> 0E-398 Clamped 170 171 -- long operand checks 172 maxexponent: 999 173 minexponent: -999 174 precision: 9 175 plux301 plus 12345678000 -> 1.23456780E+10 Rounded 176 plux302 plus 1234567800 -> 1.23456780E+9 Rounded 177 plux303 plus 1234567890 -> 1.23456789E+9 Rounded 178 plux304 plus 1234567891 -> 1.23456789E+9 Inexact Rounded 179 plux305 plus 12345678901 -> 1.23456789E+10 Inexact Rounded 180 plux306 plus 1234567896 -> 1.23456790E+9 Inexact Rounded 181 182 -- still checking 183 precision: 15 184 plux321 plus 12345678000 -> 12345678000 185 plux322 plus 1234567800 -> 1234567800 186 plux323 plus 1234567890 -> 1234567890 187 plux324 plus 1234567891 -> 1234567891 188 plux325 plus 12345678901 -> 12345678901 189 plux326 plus 1234567896 -> 1234567896 190 precision: 9 191 192 -- Null tests 193 plu900 plus # -> NaN Invalid_operation 194