1 ------------------------------------------------------------------------ 2 -- ddScalebB.decTest -- scale a decDouble by powers of 10 -- 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 precision: 16 23 maxExponent: 384 24 minExponent: -383 25 extended: 1 26 clamp: 1 27 rounding: half_even 28 29 -- Max |rhs| is 2*(384+16) = 800 30 31 -- Sanity checks 32 ddscb001 scaleb 7.50 10 -> 7.50E+10 33 ddscb002 scaleb 7.50 3 -> 7.50E+3 34 ddscb003 scaleb 7.50 2 -> 750 35 ddscb004 scaleb 7.50 1 -> 75.0 36 ddscb005 scaleb 7.50 0 -> 7.50 37 ddscb006 scaleb 7.50 -1 -> 0.750 38 ddscb007 scaleb 7.50 -2 -> 0.0750 39 ddscb008 scaleb 7.50 -10 -> 7.50E-10 40 ddscb009 scaleb -7.50 3 -> -7.50E+3 41 ddscb010 scaleb -7.50 2 -> -750 42 ddscb011 scaleb -7.50 1 -> -75.0 43 ddscb012 scaleb -7.50 0 -> -7.50 44 ddscb013 scaleb -7.50 -1 -> -0.750 45 46 -- Infinities 47 ddscb014 scaleb Infinity 1 -> Infinity 48 ddscb015 scaleb -Infinity 2 -> -Infinity 49 ddscb016 scaleb Infinity -1 -> Infinity 50 ddscb017 scaleb -Infinity -2 -> -Infinity 51 52 -- Next two are somewhat undefined in 754r; treat as non-integer 53 ddscb018 scaleb 10 Infinity -> NaN Invalid_operation 54 ddscb019 scaleb 10 -Infinity -> NaN Invalid_operation 55 56 -- NaNs are undefined in 754r; assume usual processing 57 -- NaNs, 0 payload 58 ddscb021 scaleb NaN 1 -> NaN 59 ddscb022 scaleb -NaN -1 -> -NaN 60 ddscb023 scaleb sNaN 1 -> NaN Invalid_operation 61 ddscb024 scaleb -sNaN 1 -> -NaN Invalid_operation 62 ddscb025 scaleb 4 NaN -> NaN 63 ddscb026 scaleb -Inf -NaN -> -NaN 64 ddscb027 scaleb 4 sNaN -> NaN Invalid_operation 65 ddscb028 scaleb Inf -sNaN -> -NaN Invalid_operation 66 67 -- non-integer RHS 68 ddscb030 scaleb 1.23 1 -> 12.3 69 ddscb031 scaleb 1.23 1.00 -> NaN Invalid_operation 70 ddscb032 scaleb 1.23 1.1 -> NaN Invalid_operation 71 ddscb033 scaleb 1.23 1.01 -> NaN Invalid_operation 72 ddscb034 scaleb 1.23 0.01 -> NaN Invalid_operation 73 ddscb035 scaleb 1.23 0.11 -> NaN Invalid_operation 74 ddscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation 75 ddscb037 scaleb 1.23 -1 -> 0.123 76 ddscb038 scaleb 1.23 -1.00 -> NaN Invalid_operation 77 ddscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation 78 ddscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation 79 ddscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation 80 ddscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation 81 ddscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation 82 ddscb044 scaleb 1.23 0.1 -> NaN Invalid_operation 83 ddscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation 84 ddscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation 85 ddscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation 86 87 -- out-of range RHS 88 ddscb120 scaleb 1.23 799 -> Infinity Overflow Inexact Rounded 89 ddscb121 scaleb 1.23 800 -> Infinity Overflow Inexact Rounded 90 ddscb122 scaleb 1.23 801 -> NaN Invalid_operation 91 ddscb123 scaleb 1.23 802 -> NaN Invalid_operation 92 ddscb124 scaleb 1.23 -799 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped 93 ddscb125 scaleb 1.23 -800 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped 94 ddscb126 scaleb 1.23 -801 -> NaN Invalid_operation 95 ddscb127 scaleb 1.23 -802 -> NaN Invalid_operation 96 97 -- NaNs, non-0 payload 98 -- propagating NaNs 99 ddscb861 scaleb NaN01 -Inf -> NaN1 100 ddscb862 scaleb -NaN02 -1000 -> -NaN2 101 ddscb863 scaleb NaN03 1000 -> NaN3 102 ddscb864 scaleb NaN04 Inf -> NaN4 103 ddscb865 scaleb NaN05 NaN61 -> NaN5 104 ddscb866 scaleb -Inf -NaN71 -> -NaN71 105 ddscb867 scaleb -1000 NaN81 -> NaN81 106 ddscb868 scaleb 1000 NaN91 -> NaN91 107 ddscb869 scaleb Inf NaN101 -> NaN101 108 ddscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation 109 ddscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation 110 ddscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation 111 ddscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation 112 ddscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation 113 ddscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation 114 ddscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation 115 ddscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation 116 ddscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation 117 ddscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation 118 ddscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation 119 120 -- finites 121 ddscb051 scaleb 7 -2 -> 0.07 122 ddscb052 scaleb -7 -2 -> -0.07 123 ddscb053 scaleb 75 -2 -> 0.75 124 ddscb054 scaleb -75 -2 -> -0.75 125 ddscb055 scaleb 7.50 -2 -> 0.0750 126 ddscb056 scaleb -7.50 -2 -> -0.0750 127 ddscb057 scaleb 7.500 -2 -> 0.07500 128 ddscb058 scaleb -7.500 -2 -> -0.07500 129 ddscb061 scaleb 7 -1 -> 0.7 130 ddscb062 scaleb -7 -1 -> -0.7 131 ddscb063 scaleb 75 -1 -> 7.5 132 ddscb064 scaleb -75 -1 -> -7.5 133 ddscb065 scaleb 7.50 -1 -> 0.750 134 ddscb066 scaleb -7.50 -1 -> -0.750 135 ddscb067 scaleb 7.500 -1 -> 0.7500 136 ddscb068 scaleb -7.500 -1 -> -0.7500 137 ddscb071 scaleb 7 0 -> 7 138 ddscb072 scaleb -7 0 -> -7 139 ddscb073 scaleb 75 0 -> 75 140 ddscb074 scaleb -75 0 -> -75 141 ddscb075 scaleb 7.50 0 -> 7.50 142 ddscb076 scaleb -7.50 0 -> -7.50 143 ddscb077 scaleb 7.500 0 -> 7.500 144 ddscb078 scaleb -7.500 0 -> -7.500 145 ddscb081 scaleb 7 1 -> 7E+1 146 ddscb082 scaleb -7 1 -> -7E+1 147 ddscb083 scaleb 75 1 -> 7.5E+2 148 ddscb084 scaleb -75 1 -> -7.5E+2 149 ddscb085 scaleb 7.50 1 -> 75.0 150 ddscb086 scaleb -7.50 1 -> -75.0 151 ddscb087 scaleb 7.500 1 -> 75.00 152 ddscb088 scaleb -7.500 1 -> -75.00 153 ddscb091 scaleb 7 2 -> 7E+2 154 ddscb092 scaleb -7 2 -> -7E+2 155 ddscb093 scaleb 75 2 -> 7.5E+3 156 ddscb094 scaleb -75 2 -> -7.5E+3 157 ddscb095 scaleb 7.50 2 -> 750 158 ddscb096 scaleb -7.50 2 -> -750 159 ddscb097 scaleb 7.500 2 -> 750.0 160 ddscb098 scaleb -7.500 2 -> -750.0 161 162 -- zeros 163 ddscb111 scaleb 0 1 -> 0E+1 164 ddscb112 scaleb -0 2 -> -0E+2 165 ddscb113 scaleb 0E+4 3 -> 0E+7 166 ddscb114 scaleb -0E+4 4 -> -0E+8 167 ddscb115 scaleb 0.0000 5 -> 0E+1 168 ddscb116 scaleb -0.0000 6 -> -0E+2 169 ddscb117 scaleb 0E-141 7 -> 0E-134 170 ddscb118 scaleb -0E-141 8 -> -0E-133 171 172 -- Nmax, Nmin, Ntiny 173 ddscb132 scaleb 9.999999999999999E+384 +384 -> Infinity Overflow Inexact Rounded 174 ddscb133 scaleb 9.999999999999999E+384 +10 -> Infinity Overflow Inexact Rounded 175 ddscb134 scaleb 9.999999999999999E+384 +1 -> Infinity Overflow Inexact Rounded 176 ddscb135 scaleb 9.999999999999999E+384 0 -> 9.999999999999999E+384 177 ddscb136 scaleb 9.999999999999999E+384 -1 -> 9.999999999999999E+383 178 ddscb137 scaleb 1E-383 +1 -> 1E-382 179 ddscb138 scaleb 1E-383 -0 -> 1E-383 180 ddscb139 scaleb 1E-383 -1 -> 1E-384 Subnormal 181 ddscb140 scaleb 1.000000000000000E-383 +1 -> 1.000000000000000E-382 182 ddscb141 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383 183 ddscb142 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded 184 ddscb143 scaleb 1E-398 +1 -> 1E-397 Subnormal 185 ddscb144 scaleb 1E-398 -0 -> 1E-398 Subnormal 186 ddscb145 scaleb 1E-398 -1 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped 187 188 ddscb150 scaleb -1E-398 +1 -> -1E-397 Subnormal 189 ddscb151 scaleb -1E-398 -0 -> -1E-398 Subnormal 190 ddscb152 scaleb -1E-398 -1 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped 191 ddscb153 scaleb -1.000000000000000E-383 +1 -> -1.000000000000000E-382 192 ddscb154 scaleb -1.000000000000000E-383 +0 -> -1.000000000000000E-383 193 ddscb155 scaleb -1.000000000000000E-383 -1 -> -1.00000000000000E-384 Subnormal Rounded 194 ddscb156 scaleb -1E-383 +1 -> -1E-382 195 ddscb157 scaleb -1E-383 -0 -> -1E-383 196 ddscb158 scaleb -1E-383 -1 -> -1E-384 Subnormal 197 ddscb159 scaleb -9.999999999999999E+384 +1 -> -Infinity Overflow Inexact Rounded 198 ddscb160 scaleb -9.999999999999999E+384 +0 -> -9.999999999999999E+384 199 ddscb161 scaleb -9.999999999999999E+384 -1 -> -9.999999999999999E+383 200 ddscb162 scaleb -9E+384 +1 -> -Infinity Overflow Inexact Rounded 201 ddscb163 scaleb -1E+384 +1 -> -Infinity Overflow Inexact Rounded 202 203 -- some Origami 204 -- (these check that overflow is being done correctly) 205 ddscb171 scaleb 1000E+365 +1 -> 1.000E+369 206 ddscb172 scaleb 1000E+366 +1 -> 1.000E+370 207 ddscb173 scaleb 1000E+367 +1 -> 1.000E+371 208 ddscb174 scaleb 1000E+368 +1 -> 1.000E+372 209 ddscb175 scaleb 1000E+369 +1 -> 1.0000E+373 Clamped 210 ddscb176 scaleb 1000E+370 +1 -> 1.00000E+374 Clamped 211 ddscb177 scaleb 1000E+371 +1 -> 1.000000E+375 Clamped 212 ddscb178 scaleb 1000E+372 +1 -> 1.0000000E+376 Clamped 213 ddscb179 scaleb 1000E+373 +1 -> 1.00000000E+377 Clamped 214 ddscb180 scaleb 1000E+374 +1 -> 1.000000000E+378 Clamped 215 ddscb181 scaleb 1000E+375 +1 -> 1.0000000000E+379 Clamped 216 ddscb182 scaleb 1000E+376 +1 -> 1.00000000000E+380 Clamped 217 ddscb183 scaleb 1000E+377 +1 -> 1.000000000000E+381 Clamped 218 ddscb184 scaleb 1000E+378 +1 -> 1.0000000000000E+382 Clamped 219 ddscb185 scaleb 1000E+379 +1 -> 1.00000000000000E+383 Clamped 220 ddscb186 scaleb 1000E+380 +1 -> 1.000000000000000E+384 Clamped 221 ddscb187 scaleb 1000E+381 +1 -> Infinity Overflow Inexact Rounded 222 223 -- and a few more subnormal truncations 224 -- (these check that underflow is being done correctly) 225 ddscb201 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383 226 ddscb202 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded 227 ddscb203 scaleb 1.000000000000000E-383 -2 -> 1.0000000000000E-385 Subnormal Rounded 228 ddscb204 scaleb 1.000000000000000E-383 -3 -> 1.000000000000E-386 Subnormal Rounded 229 ddscb205 scaleb 1.000000000000000E-383 -4 -> 1.00000000000E-387 Subnormal Rounded 230 ddscb206 scaleb 1.000000000000000E-383 -5 -> 1.0000000000E-388 Subnormal Rounded 231 ddscb207 scaleb 1.000000000000000E-383 -6 -> 1.000000000E-389 Subnormal Rounded 232 ddscb208 scaleb 1.000000000000000E-383 -7 -> 1.00000000E-390 Subnormal Rounded 233 ddscb209 scaleb 1.000000000000000E-383 -8 -> 1.0000000E-391 Subnormal Rounded 234 ddscb210 scaleb 1.000000000000000E-383 -9 -> 1.000000E-392 Subnormal Rounded 235 ddscb211 scaleb 1.000000000000000E-383 -10 -> 1.00000E-393 Subnormal Rounded 236 ddscb212 scaleb 1.000000000000000E-383 -11 -> 1.0000E-394 Subnormal Rounded 237 ddscb213 scaleb 1.000000000000000E-383 -12 -> 1.000E-395 Subnormal Rounded 238 ddscb214 scaleb 1.000000000000000E-383 -13 -> 1.00E-396 Subnormal Rounded 239 ddscb215 scaleb 1.000000000000000E-383 -14 -> 1.0E-397 Subnormal Rounded 240 ddscb216 scaleb 1.000000000000000E-383 -15 -> 1E-398 Subnormal Rounded 241 ddscb217 scaleb 1.000000000000000E-383 -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped 242 ddscb218 scaleb 1.000000000000000E-383 -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped 243 244