1 ------------------------------------------------------------------------ 2 -- copysign.decTest -- quiet copy with sign from rhs -- 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 extended: 1 23 precision: 9 24 rounding: half_up 25 maxExponent: 999 26 minExponent: -999 27 28 -- Sanity check, and examples from decArith 29 cpsx001 copysign +7.50 11 -> 7.50 30 cpsx002 copysign '1.50' '7.33' -> 1.50 31 cpsx003 copysign '-1.50' '7.33' -> 1.50 32 cpsx004 copysign '1.50' '-7.33' -> -1.50 33 cpsx005 copysign '-1.50' '-7.33' -> -1.50 34 35 -- Infinities 36 cpsx011 copysign Infinity 11 -> Infinity 37 cpsx012 copysign -Infinity 11 -> Infinity 38 39 -- NaNs, 0 payload 40 cpsx021 copysign NaN 11 -> NaN 41 cpsx022 copysign -NaN 11 -> NaN 42 cpsx023 copysign sNaN 11 -> sNaN 43 cpsx024 copysign -sNaN 11 -> sNaN 44 45 -- NaNs, non-0 payload 46 cpsx031 copysign NaN10 11 -> NaN10 47 cpsx032 copysign -NaN10 11 -> NaN10 48 cpsx033 copysign sNaN10 11 -> sNaN10 49 cpsx034 copysign -sNaN10 11 -> sNaN10 50 cpsx035 copysign NaN7 11 -> NaN7 51 cpsx036 copysign -NaN7 11 -> NaN7 52 cpsx037 copysign sNaN101 11 -> sNaN101 53 cpsx038 copysign -sNaN101 11 -> sNaN101 54 55 -- finites 56 cpsx101 copysign 7 11 -> 7 57 cpsx102 copysign -7 11 -> 7 58 cpsx103 copysign 75 11 -> 75 59 cpsx104 copysign -75 11 -> 75 60 cpsx105 copysign 7.50 11 -> 7.50 61 cpsx106 copysign -7.50 11 -> 7.50 62 cpsx107 copysign 7.500 11 -> 7.500 63 cpsx108 copysign -7.500 11 -> 7.500 64 65 -- zeros 66 cpsx111 copysign 0 11 -> 0 67 cpsx112 copysign -0 11 -> 0 68 cpsx113 copysign 0E+4 11 -> 0E+4 69 cpsx114 copysign -0E+4 11 -> 0E+4 70 cpsx115 copysign 0.0000 11 -> 0.0000 71 cpsx116 copysign -0.0000 11 -> 0.0000 72 cpsx117 copysign 0E-141 11 -> 0E-141 73 cpsx118 copysign -0E-141 11 -> 0E-141 74 75 -- full coefficients, alternating bits 76 cpsx121 copysign 268268268 11 -> 268268268 77 cpsx122 copysign -268268268 11 -> 268268268 78 cpsx123 copysign 134134134 11 -> 134134134 79 cpsx124 copysign -134134134 11 -> 134134134 80 81 -- Nmax, Nmin, Ntiny 82 cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999 83 cpsx132 copysign 1E-999 11 -> 1E-999 84 cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999 85 cpsx134 copysign 1E-1007 11 -> 1E-1007 86 87 cpsx135 copysign -1E-1007 11 -> 1E-1007 88 cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999 89 cpsx137 copysign -1E-999 11 -> 1E-999 90 cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999 91 92 -- repeat with negative RHS 93 94 -- Infinities 95 cpsx211 copysign Infinity -34 -> -Infinity 96 cpsx212 copysign -Infinity -34 -> -Infinity 97 98 -- NaNs, 0 payload 99 cpsx221 copysign NaN -34 -> -NaN 100 cpsx222 copysign -NaN -34 -> -NaN 101 cpsx223 copysign sNaN -34 -> -sNaN 102 cpsx224 copysign -sNaN -34 -> -sNaN 103 104 -- NaNs, non-0 payload 105 cpsx231 copysign NaN10 -34 -> -NaN10 106 cpsx232 copysign -NaN10 -34 -> -NaN10 107 cpsx233 copysign sNaN10 -34 -> -sNaN10 108 cpsx234 copysign -sNaN10 -34 -> -sNaN10 109 cpsx235 copysign NaN7 -34 -> -NaN7 110 cpsx236 copysign -NaN7 -34 -> -NaN7 111 cpsx237 copysign sNaN101 -34 -> -sNaN101 112 cpsx238 copysign -sNaN101 -34 -> -sNaN101 113 114 -- finites 115 cpsx301 copysign 7 -34 -> -7 116 cpsx302 copysign -7 -34 -> -7 117 cpsx303 copysign 75 -34 -> -75 118 cpsx304 copysign -75 -34 -> -75 119 cpsx305 copysign 7.50 -34 -> -7.50 120 cpsx306 copysign -7.50 -34 -> -7.50 121 cpsx307 copysign 7.500 -34 -> -7.500 122 cpsx308 copysign -7.500 -34 -> -7.500 123 124 -- zeros 125 cpsx311 copysign 0 -34 -> -0 126 cpsx312 copysign -0 -34 -> -0 127 cpsx313 copysign 0E+4 -34 -> -0E+4 128 cpsx314 copysign -0E+4 -34 -> -0E+4 129 cpsx315 copysign 0.0000 -34 -> -0.0000 130 cpsx316 copysign -0.0000 -34 -> -0.0000 131 cpsx317 copysign 0E-141 -34 -> -0E-141 132 cpsx318 copysign -0E-141 -34 -> -0E-141 133 134 -- full coefficients, alternating bits 135 cpsx321 copysign 268268268 -18 -> -268268268 136 cpsx322 copysign -268268268 -18 -> -268268268 137 cpsx323 copysign 134134134 -18 -> -134134134 138 cpsx324 copysign -134134134 -18 -> -134134134 139 140 -- Nmax, Nmin, Ntiny 141 cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999 142 cpsx332 copysign 1E-999 -18 -> -1E-999 143 cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999 144 cpsx334 copysign 1E-1007 -18 -> -1E-1007 145 146 cpsx335 copysign -1E-1007 -18 -> -1E-1007 147 cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999 148 cpsx337 copysign -1E-999 -18 -> -1E-999 149 cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999 150 151 -- Other kinds of RHS 152 cpsx401 copysign 701 -34 -> -701 153 cpsx402 copysign -720 -34 -> -720 154 cpsx403 copysign 701 -0 -> -701 155 cpsx404 copysign -720 -0 -> -720 156 cpsx405 copysign 701 +0 -> 701 157 cpsx406 copysign -720 +0 -> 720 158 cpsx407 copysign 701 +34 -> 701 159 cpsx408 copysign -720 +34 -> 720 160 161 cpsx413 copysign 701 -Inf -> -701 162 cpsx414 copysign -720 -Inf -> -720 163 cpsx415 copysign 701 +Inf -> 701 164 cpsx416 copysign -720 +Inf -> 720 165 166 cpsx420 copysign 701 -NaN -> -701 167 cpsx421 copysign -720 -NaN -> -720 168 cpsx422 copysign 701 +NaN -> 701 169 cpsx423 copysign -720 +NaN -> 720 170 cpsx425 copysign -720 +NaN8 -> 720 171 172 cpsx426 copysign 701 -sNaN -> -701 173 cpsx427 copysign -720 -sNaN -> -720 174 cpsx428 copysign 701 +sNaN -> 701 175 cpsx429 copysign -720 +sNaN -> 720 176 cpsx430 copysign -720 +sNaN3 -> 720 177 178