Repository URL to install this package:
------------------------------------------------------------------------ -- ddBase.decTest -- base decDouble <--> string conversions -- -- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. -- ------------------------------------------------------------------------ -- Please see the document "General Decimal Arithmetic Testcases" -- -- at http://www2.hursley.ibm.com/decimal for the description of -- -- these testcases. -- -- -- -- These testcases are experimental ('beta' versions), and they -- -- may contain errors. They are offered on an as-is basis. In -- -- particular, achieving the same results as the tests here is not -- -- a guarantee that an implementation complies with any Standard -- -- or specification. The tests are not exhaustive. -- -- -- -- Please send comments, suggestions, and corrections to the author: -- -- Mike Cowlishaw, IBM Fellow -- -- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- -- mfc@uk.ibm.com -- ------------------------------------------------------------------------ version: 2.59 -- This file tests base conversions from string to a decimal number -- and back to a string (in Scientific form) -- Note that unlike other operations the operand is subject to rounding -- to conform to emax and precision settings (that is, numbers will -- conform to rules and exponent will be in permitted range). The -- 'left hand side', therefore, may have numbers that cannot be -- represented in a decDouble. Some testcases go to the limit of the -- next-wider format, and hence these testcases may also be used to -- test narrowing and widening operations. precision: 16 maxExponent: 384 minExponent: -383 extended: 1 clamp: 1 rounding: half_even ddbas001 toSci 0 -> 0 ddbas002 toSci 1 -> 1 ddbas003 toSci 1.0 -> 1.0 ddbas004 toSci 1.00 -> 1.00 ddbas005 toSci 10 -> 10 ddbas006 toSci 1000 -> 1000 ddbas007 toSci 10.0 -> 10.0 ddbas008 toSci 10.1 -> 10.1 ddbas009 toSci 10.4 -> 10.4 ddbas010 toSci 10.5 -> 10.5 ddbas011 toSci 10.6 -> 10.6 ddbas012 toSci 10.9 -> 10.9 ddbas013 toSci 11.0 -> 11.0 ddbas014 toSci 1.234 -> 1.234 ddbas015 toSci 0.123 -> 0.123 ddbas016 toSci 0.012 -> 0.012 ddbas017 toSci -0 -> -0 ddbas018 toSci -0.0 -> -0.0 ddbas019 toSci -00.00 -> -0.00 ddbas021 toSci -1 -> -1 ddbas022 toSci -1.0 -> -1.0 ddbas023 toSci -0.1 -> -0.1 ddbas024 toSci -9.1 -> -9.1 ddbas025 toSci -9.11 -> -9.11 ddbas026 toSci -9.119 -> -9.119 ddbas027 toSci -9.999 -> -9.999 ddbas030 toSci '123456789.123456' -> '123456789.123456' ddbas031 toSci '123456789.000000' -> '123456789.000000' ddbas032 toSci '123456789123456' -> '123456789123456' ddbas033 toSci '0.0000123456789' -> '0.0000123456789' ddbas034 toSci '0.00000123456789' -> '0.00000123456789' ddbas035 toSci '0.000000123456789' -> '1.23456789E-7' ddbas036 toSci '0.0000000123456789' -> '1.23456789E-8' ddbas037 toSci '0.123456789012344' -> '0.123456789012344' ddbas038 toSci '0.123456789012345' -> '0.123456789012345' -- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax) ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384 ddbsn002 toSci -1E-383 -> -1E-383 ddbsn003 toSci -1E-398 -> -1E-398 Subnormal ddbsn004 toSci -0 -> -0 ddbsn005 toSci +0 -> 0 ddbsn006 toSci +1E-398 -> 1E-398 Subnormal ddbsn007 toSci +1E-383 -> 1E-383 ddbsn008 toSci +9.999999999999999E+384 -> 9.999999999999999E+384 -- String [many more examples are implicitly tested elsewhere] -- strings without E cannot generate E in result ddbas040 toSci "12" -> '12' ddbas041 toSci "-76" -> '-76' ddbas042 toSci "12.76" -> '12.76' ddbas043 toSci "+12.76" -> '12.76' ddbas044 toSci "012.76" -> '12.76' ddbas045 toSci "+0.003" -> '0.003' ddbas046 toSci "17." -> '17' ddbas047 toSci ".5" -> '0.5' ddbas048 toSci "044" -> '44' ddbas049 toSci "0044" -> '44' ddbas050 toSci "0.0005" -> '0.0005' ddbas051 toSci "00.00005" -> '0.00005' ddbas052 toSci "0.000005" -> '0.000005' ddbas053 toSci "0.0000050" -> '0.0000050' ddbas054 toSci "0.0000005" -> '5E-7' ddbas055 toSci "0.00000005" -> '5E-8' ddbas056 toSci "12345678.543210" -> '12345678.543210' ddbas057 toSci "2345678.543210" -> '2345678.543210' ddbas058 toSci "345678.543210" -> '345678.543210' ddbas059 toSci "0345678.54321" -> '345678.54321' ddbas060 toSci "345678.5432" -> '345678.5432' ddbas061 toSci "+345678.5432" -> '345678.5432' ddbas062 toSci "+0345678.5432" -> '345678.5432' ddbas063 toSci "+00345678.5432" -> '345678.5432' ddbas064 toSci "-345678.5432" -> '-345678.5432' ddbas065 toSci "-0345678.5432" -> '-345678.5432' ddbas066 toSci "-00345678.5432" -> '-345678.5432' -- examples ddbas067 toSci "5E-6" -> '0.000005' ddbas068 toSci "50E-7" -> '0.0000050' ddbas069 toSci "5E-7" -> '5E-7' -- [No exotics as no Unicode] -- rounded with dots in all (including edge) places ddbas071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded ddbas072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded ddbas073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded ddbas074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded ddbas075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded ddbas076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded ddbas077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded ddbas078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded ddbas079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded ddbas080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded ddbas081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded ddbas082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded ddbas083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded ddbas084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded ddbas085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded ddbas086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded ddbas087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded ddbas088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded ddbas089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded ddbas090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded -- Numbers with E ddbas130 toSci "0.000E-1" -> '0.0000' ddbas131 toSci "0.000E-2" -> '0.00000' ddbas132 toSci "0.000E-3" -> '0.000000' ddbas133 toSci "0.000E-4" -> '0E-7' ddbas134 toSci "0.00E-2" -> '0.0000' ddbas135 toSci "0.00E-3" -> '0.00000' ddbas136 toSci "0.00E-4" -> '0.000000' ddbas137 toSci "0.00E-5" -> '0E-7' ddbas138 toSci "+0E+9" -> '0E+9' ddbas139 toSci "-0E+9" -> '-0E+9' ddbas140 toSci "1E+9" -> '1E+9' ddbas141 toSci "1e+09" -> '1E+9' ddbas142 toSci "1E+90" -> '1E+90' ddbas143 toSci "+1E+009" -> '1E+9' ddbas144 toSci "0E+9" -> '0E+9' ddbas145 toSci "1E+9" -> '1E+9' ddbas146 toSci "1E+09" -> '1E+9' ddbas147 toSci "1e+90" -> '1E+90' ddbas148 toSci "1E+009" -> '1E+9' ddbas149 toSci "000E+9" -> '0E+9' ddbas150 toSci "1E9" -> '1E+9' ddbas151 toSci "1e09" -> '1E+9' ddbas152 toSci "1E90" -> '1E+90' ddbas153 toSci "1E009" -> '1E+9' ddbas154 toSci "0E9" -> '0E+9' ddbas155 toSci "0.000e+0" -> '0.000' ddbas156 toSci "0.000E-1" -> '0.0000' ddbas157 toSci "4E+9" -> '4E+9' ddbas158 toSci "44E+9" -> '4.4E+10' ddbas159 toSci "0.73e-7" -> '7.3E-8' ddbas160 toSci "00E+9" -> '0E+9' ddbas161 toSci "00E-9" -> '0E-9' ddbas162 toSci "10E+9" -> '1.0E+10' ddbas163 toSci "10E+09" -> '1.0E+10' ddbas164 toSci "10e+90" -> '1.0E+91' ddbas165 toSci "10E+009" -> '1.0E+10' ddbas166 toSci "100e+9" -> '1.00E+11' ddbas167 toSci "100e+09" -> '1.00E+11' ddbas168 toSci "100E+90" -> '1.00E+92' ddbas169 toSci "100e+009" -> '1.00E+11' ddbas170 toSci "1.265" -> '1.265' ddbas171 toSci "1.265E-20" -> '1.265E-20' ddbas172 toSci "1.265E-8" -> '1.265E-8' ddbas173 toSci "1.265E-4" -> '0.0001265' ddbas174 toSci "1.265E-3" -> '0.001265' ddbas175 toSci "1.265E-2" -> '0.01265' ddbas176 toSci "1.265E-1" -> '0.1265' ddbas177 toSci "1.265E-0" -> '1.265' ddbas178 toSci "1.265E+1" -> '12.65' ddbas179 toSci "1.265E+2" -> '126.5' ddbas180 toSci "1.265E+3" -> '1265' ddbas181 toSci "1.265E+4" -> '1.265E+4' ddbas182 toSci "1.265E+8" -> '1.265E+8' ddbas183 toSci "1.265E+20" -> '1.265E+20' ddbas190 toSci "12.65" -> '12.65' ddbas191 toSci "12.65E-20" -> '1.265E-19' ddbas192 toSci "12.65E-8" -> '1.265E-7' ddbas193 toSci "12.65E-4" -> '0.001265' ddbas194 toSci "12.65E-3" -> '0.01265' ddbas195 toSci "12.65E-2" -> '0.1265' ddbas196 toSci "12.65E-1" -> '1.265' ddbas197 toSci "12.65E-0" -> '12.65' ddbas198 toSci "12.65E+1" -> '126.5' ddbas199 toSci "12.65E+2" -> '1265' ddbas200 toSci "12.65E+3" -> '1.265E+4' ddbas201 toSci "12.65E+4" -> '1.265E+5' ddbas202 toSci "12.65E+8" -> '1.265E+9' ddbas203 toSci "12.65E+20" -> '1.265E+21' ddbas210 toSci "126.5" -> '126.5' ddbas211 toSci "126.5E-20" -> '1.265E-18' ddbas212 toSci "126.5E-8" -> '0.000001265' ddbas213 toSci "126.5E-4" -> '0.01265' ddbas214 toSci "126.5E-3" -> '0.1265' ddbas215 toSci "126.5E-2" -> '1.265' ddbas216 toSci "126.5E-1" -> '12.65' ddbas217 toSci "126.5E-0" -> '126.5' ddbas218 toSci "126.5E+1" -> '1265' ddbas219 toSci "126.5E+2" -> '1.265E+4' ddbas220 toSci "126.5E+3" -> '1.265E+5' ddbas221 toSci "126.5E+4" -> '1.265E+6' ddbas222 toSci "126.5E+8" -> '1.265E+10' ddbas223 toSci "126.5E+20" -> '1.265E+22' ddbas230 toSci "1265" -> '1265' ddbas231 toSci "1265E-20" -> '1.265E-17' ddbas232 toSci "1265E-8" -> '0.00001265' ddbas233 toSci "1265E-4" -> '0.1265' ddbas234 toSci "1265E-3" -> '1.265' ddbas235 toSci "1265E-2" -> '12.65' ddbas236 toSci "1265E-1" -> '126.5' ddbas237 toSci "1265E-0" -> '1265' ddbas238 toSci "1265E+1" -> '1.265E+4' ddbas239 toSci "1265E+2" -> '1.265E+5' ddbas240 toSci "1265E+3" -> '1.265E+6' ddbas241 toSci "1265E+4" -> '1.265E+7' ddbas242 toSci "1265E+8" -> '1.265E+11' ddbas243 toSci "1265E+20" -> '1.265E+23' ddbas244 toSci "1265E-9" -> '0.000001265' ddbas245 toSci "1265E-10" -> '1.265E-7' ddbas246 toSci "1265E-11" -> '1.265E-8' ddbas247 toSci "1265E-12" -> '1.265E-9' ddbas250 toSci "0.1265" -> '0.1265' ddbas251 toSci "0.1265E-20" -> '1.265E-21' ddbas252 toSci "0.1265E-8" -> '1.265E-9' ddbas253 toSci "0.1265E-4" -> '0.00001265' ddbas254 toSci "0.1265E-3" -> '0.0001265' ddbas255 toSci "0.1265E-2" -> '0.001265' ddbas256 toSci "0.1265E-1" -> '0.01265' ddbas257 toSci "0.1265E-0" -> '0.1265' ddbas258 toSci "0.1265E+1" -> '1.265' ddbas259 toSci "0.1265E+2" -> '12.65' ddbas260 toSci "0.1265E+3" -> '126.5' ddbas261 toSci "0.1265E+4" -> '1265' ddbas262 toSci "0.1265E+8" -> '1.265E+7' ddbas263 toSci "0.1265E+20" -> '1.265E+19' -- some more negative zeros [systematic tests below] ddbas290 toSci "-0.000E-1" -> '-0.0000' ddbas291 toSci "-0.000E-2" -> '-0.00000' ddbas292 toSci "-0.000E-3" -> '-0.000000' ddbas293 toSci "-0.000E-4" -> '-0E-7' ddbas294 toSci "-0.00E-2" -> '-0.0000' ddbas295 toSci "-0.00E-3" -> '-0.00000' ddbas296 toSci "-0.0E-2" -> '-0.000' ddbas297 toSci "-0.0E-3" -> '-0.0000' ddbas298 toSci "-0E-2" -> '-0.00' ddbas299 toSci "-0E-3" -> '-0.000' -- Engineering notation tests ddbas301 toSci 10e12 -> 1.0E+13 ddbas302 toEng 10e12 -> 10E+12 ddbas303 toSci 10e11 -> 1.0E+12 ddbas304 toEng 10e11 -> 1.0E+12 ddbas305 toSci 10e10 -> 1.0E+11 ddbas306 toEng 10e10 -> 100E+9 ddbas307 toSci 10e9 -> 1.0E+10 ddbas308 toEng 10e9 -> 10E+9 ddbas309 toSci 10e8 -> 1.0E+9 ddbas310 toEng 10e8 -> 1.0E+9 ddbas311 toSci 10e7 -> 1.0E+8 ddbas312 toEng 10e7 -> 100E+6 ddbas313 toSci 10e6 -> 1.0E+7 ddbas314 toEng 10e6 -> 10E+6 ddbas315 toSci 10e5 -> 1.0E+6 ddbas316 toEng 10e5 -> 1.0E+6 ddbas317 toSci 10e4 -> 1.0E+5 ddbas318 toEng 10e4 -> 100E+3 ddbas319 toSci 10e3 -> 1.0E+4 ddbas320 toEng 10e3 -> 10E+3 ddbas321 toSci 10e2 -> 1.0E+3 ddbas322 toEng 10e2 -> 1.0E+3 ddbas323 toSci 10e1 -> 1.0E+2 ddbas324 toEng 10e1 -> 100 ddbas325 toSci 10e0 -> 10 ddbas326 toEng 10e0 -> 10 ddbas327 toSci 10e-1 -> 1.0 ddbas328 toEng 10e-1 -> 1.0 ddbas329 toSci 10e-2 -> 0.10 ddbas330 toEng 10e-2 -> 0.10 ddbas331 toSci 10e-3 -> 0.010 ddbas332 toEng 10e-3 -> 0.010 ddbas333 toSci 10e-4 -> 0.0010 ddbas334 toEng 10e-4 -> 0.0010 ddbas335 toSci 10e-5 -> 0.00010 ddbas336 toEng 10e-5 -> 0.00010 ddbas337 toSci 10e-6 -> 0.000010 ddbas338 toEng 10e-6 -> 0.000010 ddbas339 toSci 10e-7 -> 0.0000010 ddbas340 toEng 10e-7 -> 0.0000010 ddbas341 toSci 10e-8 -> 1.0E-7 ddbas342 toEng 10e-8 -> 100E-9 ddbas343 toSci 10e-9 -> 1.0E-8 ddbas344 toEng 10e-9 -> 10E-9 ddbas345 toSci 10e-10 -> 1.0E-9 ddbas346 toEng 10e-10 -> 1.0E-9 ddbas347 toSci 10e-11 -> 1.0E-10 ddbas348 toEng 10e-11 -> 100E-12 ddbas349 toSci 10e-12 -> 1.0E-11 ddbas350 toEng 10e-12 -> 10E-12 ddbas351 toSci 10e-13 -> 1.0E-12 ddbas352 toEng 10e-13 -> 1.0E-12 ddbas361 toSci 7E12 -> 7E+12 ddbas362 toEng 7E12 -> 7E+12 ddbas363 toSci 7E11 -> 7E+11 ddbas364 toEng 7E11 -> 700E+9 ddbas365 toSci 7E10 -> 7E+10 ddbas366 toEng 7E10 -> 70E+9 ddbas367 toSci 7E9 -> 7E+9 ddbas368 toEng 7E9 -> 7E+9 ddbas369 toSci 7E8 -> 7E+8 ddbas370 toEng 7E8 -> 700E+6 ddbas371 toSci 7E7 -> 7E+7Loading ...