1 ------------------------------------------------------------------------ 2 -- minus.decTest -- decimal negation -- 3 -- Copyright (c) IBM Corporation, 1981, 2008. 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 (a] uk.ibm.com -- 19 ------------------------------------------------------------------------ 20 version: 2.59 21 22 -- This set of tests primarily tests the existence of the operator. 23 -- Subtraction, rounding, and more overflows are tested elsewhere. 24 25 extended: 1 26 precision: 9 27 rounding: half_up 28 maxExponent: 384 29 minexponent: -383 30 31 minx001 minus '1' -> '-1' 32 minx002 minus '-1' -> '1' 33 minx003 minus '1.00' -> '-1.00' 34 minx004 minus '-1.00' -> '1.00' 35 minx005 minus '0' -> '0' 36 minx006 minus '0.00' -> '0.00' 37 minx007 minus '00.0' -> '0.0' 38 minx008 minus '00.00' -> '0.00' 39 minx009 minus '00' -> '0' 40 41 minx010 minus '-2' -> '2' 42 minx011 minus '2' -> '-2' 43 minx012 minus '-2.00' -> '2.00' 44 minx013 minus '2.00' -> '-2.00' 45 minx014 minus '-0' -> '0' 46 minx015 minus '-0.00' -> '0.00' 47 minx016 minus '-00.0' -> '0.0' 48 minx017 minus '-00.00' -> '0.00' 49 minx018 minus '-00' -> '0' 50 51 -- "lhs" zeros in plus and minus have exponent = operand 52 minx020 minus '-0E3' -> '0E+3' 53 minx021 minus '-0E2' -> '0E+2' 54 minx022 minus '-0E1' -> '0E+1' 55 minx023 minus '-0E0' -> '0' 56 minx024 minus '+0E0' -> '0' 57 minx025 minus '+0E1' -> '0E+1' 58 minx026 minus '+0E2' -> '0E+2' 59 minx027 minus '+0E3' -> '0E+3' 60 61 minx030 minus '-5E3' -> '5E+3' 62 minx031 minus '-5E8' -> '5E+8' 63 minx032 minus '-5E13' -> '5E+13' 64 minx033 minus '-5E18' -> '5E+18' 65 minx034 minus '+5E3' -> '-5E+3' 66 minx035 minus '+5E8' -> '-5E+8' 67 minx036 minus '+5E13' -> '-5E+13' 68 minx037 minus '+5E18' -> '-5E+18' 69 70 minx050 minus '-2000000' -> '2000000' 71 minx051 minus '2000000' -> '-2000000' 72 precision: 7 73 minx052 minus '-2000000' -> '2000000' 74 minx053 minus '2000000' -> '-2000000' 75 precision: 6 76 minx054 minus '-2000000' -> '2.00000E+6' Rounded 77 minx055 minus '2000000' -> '-2.00000E+6' Rounded 78 precision: 3 79 minx056 minus '-2000000' -> '2.00E+6' Rounded 80 minx057 minus '2000000' -> '-2.00E+6' Rounded 81 82 -- more fixed, potential LHS swaps/overlays if done by 0 subtract x 83 precision: 9 84 minx060 minus '56267E-10' -> '-0.0000056267' 85 minx061 minus '56267E-5' -> '-0.56267' 86 minx062 minus '56267E-2' -> '-562.67' 87 minx063 minus '56267E-1' -> '-5626.7' 88 minx065 minus '56267E-0' -> '-56267' 89 minx066 minus '56267E+0' -> '-56267' 90 minx067 minus '56267E+1' -> '-5.6267E+5' 91 minx068 minus '56267E+2' -> '-5.6267E+6' 92 minx069 minus '56267E+3' -> '-5.6267E+7' 93 minx070 minus '56267E+4' -> '-5.6267E+8' 94 minx071 minus '56267E+5' -> '-5.6267E+9' 95 minx072 minus '56267E+6' -> '-5.6267E+10' 96 minx080 minus '-56267E-10' -> '0.0000056267' 97 minx081 minus '-56267E-5' -> '0.56267' 98 minx082 minus '-56267E-2' -> '562.67' 99 minx083 minus '-56267E-1' -> '5626.7' 100 minx085 minus '-56267E-0' -> '56267' 101 minx086 minus '-56267E+0' -> '56267' 102 minx087 minus '-56267E+1' -> '5.6267E+5' 103 minx088 minus '-56267E+2' -> '5.6267E+6' 104 minx089 minus '-56267E+3' -> '5.6267E+7' 105 minx090 minus '-56267E+4' -> '5.6267E+8' 106 minx091 minus '-56267E+5' -> '5.6267E+9' 107 minx092 minus '-56267E+6' -> '5.6267E+10' 108 109 110 -- overflow tests 111 maxexponent: 999999999 112 minexponent: -999999999 113 precision: 3 114 minx100 minus 9.999E+999999999 -> -Infinity Inexact Overflow Rounded 115 minx101 minus -9.999E+999999999 -> Infinity Inexact Overflow Rounded 116 117 -- subnormals and underflow 118 precision: 3 119 maxexponent: 999 120 minexponent: -999 121 minx110 minus 1.00E-999 -> -1.00E-999 122 minx111 minus 0.1E-999 -> -1E-1000 Subnormal 123 minx112 minus 0.10E-999 -> -1.0E-1000 Subnormal 124 minx113 minus 0.100E-999 -> -1.0E-1000 Subnormal Rounded 125 minx114 minus 0.01E-999 -> -1E-1001 Subnormal 126 -- next is rounded to Emin 127 minx115 minus 0.999E-999 -> -1.00E-999 Inexact Rounded Subnormal Underflow 128 minx116 minus 0.099E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow 129 minx117 minus 0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow 130 minx118 minus 0.001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 131 minx119 minus 0.0009E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 132 minx120 minus 0.0001E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped 133 134 minx130 minus -1.00E-999 -> 1.00E-999 135 minx131 minus -0.1E-999 -> 1E-1000 Subnormal 136 minx132 minus -0.10E-999 -> 1.0E-1000 Subnormal 137 minx133 minus -0.100E-999 -> 1.0E-1000 Subnormal Rounded 138 minx134 minus -0.01E-999 -> 1E-1001 Subnormal 139 -- next is rounded to Emin 140 minx135 minus -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow 141 minx136 minus -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow 142 minx137 minus -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow 143 minx138 minus -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 144 minx139 minus -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 145 minx140 minus -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped 146 147 148 -- long operand checks 149 maxexponent: 999 150 minexponent: -999 151 precision: 9 152 minx301 minus 12345678000 -> -1.23456780E+10 Rounded 153 minx302 minus 1234567800 -> -1.23456780E+9 Rounded 154 minx303 minus 1234567890 -> -1.23456789E+9 Rounded 155 minx304 minus 1234567891 -> -1.23456789E+9 Inexact Rounded 156 minx305 minus 12345678901 -> -1.23456789E+10 Inexact Rounded 157 minx306 minus 1234567896 -> -1.23456790E+9 Inexact Rounded 158 159 precision: 15 160 -- still checking 161 minx321 minus 12345678000 -> -12345678000 162 minx322 minus 1234567800 -> -1234567800 163 minx323 minus 1234567890 -> -1234567890 164 minx324 minus 1234567891 -> -1234567891 165 minx325 minus 12345678901 -> -12345678901 166 minx326 minus 1234567896 -> -1234567896 167 168 -- specials 169 minx420 minus 'Inf' -> '-Infinity' 170 minx421 minus '-Inf' -> 'Infinity' 171 minx422 minus NaN -> NaN 172 minx423 minus sNaN -> NaN Invalid_operation 173 minx424 minus NaN255 -> NaN255 174 minx425 minus sNaN256 -> NaN256 Invalid_operation 175 minx426 minus -NaN -> -NaN 176 minx427 minus -sNaN -> -NaN Invalid_operation 177 minx428 minus -NaN255 -> -NaN255 178 minx429 minus -sNaN256 -> -NaN256 Invalid_operation 179 180 -- Null tests 181 minx900 minus # -> NaN Invalid_operation 182 183