Repository URL to install this package:
------------------------------------------------------------------------ -- dqBase.decTest -- base decQuad <--> 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 decQuad. 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. extended: 1 clamp: 1 precision: 34 maxExponent: 6144 minExponent: -6143 rounding: half_even dqbas001 toSci 0 -> 0 dqbas002 toSci 1 -> 1 dqbas003 toSci 1.0 -> 1.0 dqbas004 toSci 1.00 -> 1.00 dqbas005 toSci 10 -> 10 dqbas006 toSci 1000 -> 1000 dqbas007 toSci 10.0 -> 10.0 dqbas008 toSci 10.1 -> 10.1 dqbas009 toSci 10.4 -> 10.4 dqbas010 toSci 10.5 -> 10.5 dqbas011 toSci 10.6 -> 10.6 dqbas012 toSci 10.9 -> 10.9 dqbas013 toSci 11.0 -> 11.0 dqbas014 toSci 1.234 -> 1.234 dqbas015 toSci 0.123 -> 0.123 dqbas016 toSci 0.012 -> 0.012 dqbas017 toSci -0 -> -0 dqbas018 toSci -0.0 -> -0.0 dqbas019 toSci -00.00 -> -0.00 dqbas021 toSci -1 -> -1 dqbas022 toSci -1.0 -> -1.0 dqbas023 toSci -0.1 -> -0.1 dqbas024 toSci -9.1 -> -9.1 dqbas025 toSci -9.11 -> -9.11 dqbas026 toSci -9.119 -> -9.119 dqbas027 toSci -9.999 -> -9.999 dqbas030 toSci '123456789.123456' -> '123456789.123456' dqbas031 toSci '123456789.000000' -> '123456789.000000' dqbas032 toSci '123456789123456' -> '123456789123456' dqbas033 toSci '0.0000123456789' -> '0.0000123456789' dqbas034 toSci '0.00000123456789' -> '0.00000123456789' dqbas035 toSci '0.000000123456789' -> '1.23456789E-7' dqbas036 toSci '0.0000000123456789' -> '1.23456789E-8' dqbas037 toSci '0.123456789012344' -> '0.123456789012344' dqbas038 toSci '0.123456789012345' -> '0.123456789012345' -- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax) dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144 dqbsn002 toSci -1E-6143 -> -1E-6143 dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal dqbsn004 toSci -0 -> -0 dqbsn005 toSci +0 -> 0 dqbsn006 toSci +1E-6176 -> 1E-6176 Subnormal dqbsn007 toSci +1E-6143 -> 1E-6143 dqbsn008 toSci +9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144 -- String [many more examples are implicitly tested elsewhere] -- strings without E cannot generate E in result dqbas040 toSci "12" -> '12' dqbas041 toSci "-76" -> '-76' dqbas042 toSci "12.76" -> '12.76' dqbas043 toSci "+12.76" -> '12.76' dqbas044 toSci "012.76" -> '12.76' dqbas045 toSci "+0.003" -> '0.003' dqbas046 toSci "17." -> '17' dqbas047 toSci ".5" -> '0.5' dqbas048 toSci "044" -> '44' dqbas049 toSci "0044" -> '44' dqbas050 toSci "0.0005" -> '0.0005' dqbas051 toSci "00.00005" -> '0.00005' dqbas052 toSci "0.000005" -> '0.000005' dqbas053 toSci "0.0000050" -> '0.0000050' dqbas054 toSci "0.0000005" -> '5E-7' dqbas055 toSci "0.00000005" -> '5E-8' dqbas056 toSci "12345678.543210" -> '12345678.543210' dqbas057 toSci "2345678.543210" -> '2345678.543210' dqbas058 toSci "345678.543210" -> '345678.543210' dqbas059 toSci "0345678.54321" -> '345678.54321' dqbas060 toSci "345678.5432" -> '345678.5432' dqbas061 toSci "+345678.5432" -> '345678.5432' dqbas062 toSci "+0345678.5432" -> '345678.5432' dqbas063 toSci "+00345678.5432" -> '345678.5432' dqbas064 toSci "-345678.5432" -> '-345678.5432' dqbas065 toSci "-0345678.5432" -> '-345678.5432' dqbas066 toSci "-00345678.5432" -> '-345678.5432' -- examples dqbas067 toSci "5E-6" -> '0.000005' dqbas068 toSci "50E-7" -> '0.0000050' dqbas069 toSci "5E-7" -> '5E-7' -- [No exotics as no Unicode] -- rounded with dots in all (including edge) places dqbas071 toSci .1234567891234567890123456780123456123 -> 0.1234567891234567890123456780123456 Inexact Rounded dqbas072 toSci 1.234567891234567890123456780123456123 -> 1.234567891234567890123456780123456 Inexact Rounded dqbas073 toSci 12.34567891234567890123456780123456123 -> 12.34567891234567890123456780123456 Inexact Rounded dqbas074 toSci 123.4567891234567890123456780123456123 -> 123.4567891234567890123456780123456 Inexact Rounded dqbas075 toSci 1234.567891234567890123456780123456123 -> 1234.567891234567890123456780123456 Inexact Rounded dqbas076 toSci 12345.67891234567890123456780123456123 -> 12345.67891234567890123456780123456 Inexact Rounded dqbas077 toSci 123456.7891234567890123456780123456123 -> 123456.7891234567890123456780123456 Inexact Rounded dqbas078 toSci 1234567.891234567890123456780123456123 -> 1234567.891234567890123456780123456 Inexact Rounded dqbas079 toSci 12345678.91234567890123456780123456123 -> 12345678.91234567890123456780123456 Inexact Rounded dqbas080 toSci 123456789.1234567890123456780123456123 -> 123456789.1234567890123456780123456 Inexact Rounded dqbas081 toSci 1234567891.234567890123456780123456123 -> 1234567891.234567890123456780123456 Inexact Rounded dqbas082 toSci 12345678912.34567890123456780123456123 -> 12345678912.34567890123456780123456 Inexact Rounded dqbas083 toSci 123456789123.4567890123456780123456123 -> 123456789123.4567890123456780123456 Inexact Rounded dqbas084 toSci 1234567891234.567890123456780123456123 -> 1234567891234.567890123456780123456 Inexact Rounded dqbas085 toSci 12345678912345.67890123456780123456123 -> 12345678912345.67890123456780123456 Inexact Rounded dqbas086 toSci 123456789123456.7890123456780123456123 -> 123456789123456.7890123456780123456 Inexact Rounded dqbas087 toSci 1234567891234567.890123456780123456123 -> 1234567891234567.890123456780123456 Inexact Rounded dqbas088 toSci 12345678912345678.90123456780123456123 -> 12345678912345678.90123456780123456 Inexact Rounded dqbas089 toSci 123456789123456789.0123456780123456123 -> 123456789123456789.0123456780123456 Inexact Rounded dqbas090 toSci 1234567891234567890.123456780123456123 -> 1234567891234567890.123456780123456 Inexact Rounded dqbas091 toSci 12345678912345678901.23456780123456123 -> 12345678912345678901.23456780123456 Inexact Rounded dqbas092 toSci 123456789123456789012.3456780123456123 -> 123456789123456789012.3456780123456 Inexact Rounded dqbas093 toSci 1234567891234567890123.456780123456123 -> 1234567891234567890123.456780123456 Inexact Rounded dqbas094 toSci 12345678912345678901234.56780123456123 -> 12345678912345678901234.56780123456 Inexact Rounded dqbas095 toSci 123456789123456789012345.6780123456123 -> 123456789123456789012345.6780123456 Inexact Rounded dqbas096 toSci 1234567891234567890123456.780123456123 -> 1234567891234567890123456.780123456 Inexact Rounded dqbas097 toSci 12345678912345678901234567.80123456123 -> 12345678912345678901234567.80123456 Inexact Rounded dqbas098 toSci 123456789123456789012345678.0123456123 -> 123456789123456789012345678.0123456 Inexact Rounded dqbas099 toSci 1234567891234567890123456780.123456123 -> 1234567891234567890123456780.123456 Inexact Rounded dqbas100 toSci 12345678912345678901234567801.23456123 -> 12345678912345678901234567801.23456 Inexact Rounded dqbas101 toSci 123456789123456789012345678012.3456123 -> 123456789123456789012345678012.3456 Inexact Rounded dqbas102 toSci 1234567891234567890123456780123.456123 -> 1234567891234567890123456780123.456 Inexact Rounded dqbas103 toSci 12345678912345678901234567801234.56123 -> 12345678912345678901234567801234.56 Inexact Rounded dqbas104 toSci 123456789123456789012345678012345.6123 -> 123456789123456789012345678012345.6 Inexact Rounded dqbas105 toSci 1234567891234567890123456780123456.123 -> 1234567891234567890123456780123456 Inexact Rounded dqbas106 toSci 12345678912345678901234567801234561.23 -> 1.234567891234567890123456780123456E+34 Inexact Rounded dqbas107 toSci 123456789123456789012345678012345612.3 -> 1.234567891234567890123456780123456E+35 Inexact Rounded dqbas108 toSci 1234567891234567890123456780123456123. -> 1.234567891234567890123456780123456E+36 Inexact Rounded -- 123456789012345678 -- Numbers with E dqbas130 toSci "0.000E-1" -> '0.0000' dqbas131 toSci "0.000E-2" -> '0.00000' dqbas132 toSci "0.000E-3" -> '0.000000' dqbas133 toSci "0.000E-4" -> '0E-7' dqbas134 toSci "0.00E-2" -> '0.0000' dqbas135 toSci "0.00E-3" -> '0.00000' dqbas136 toSci "0.00E-4" -> '0.000000' dqbas137 toSci "0.00E-5" -> '0E-7' dqbas138 toSci "+0E+9" -> '0E+9' dqbas139 toSci "-0E+9" -> '-0E+9' dqbas140 toSci "1E+9" -> '1E+9' dqbas141 toSci "1e+09" -> '1E+9' dqbas142 toSci "1E+90" -> '1E+90' dqbas143 toSci "+1E+009" -> '1E+9' dqbas144 toSci "0E+9" -> '0E+9' dqbas145 toSci "1E+9" -> '1E+9' dqbas146 toSci "1E+09" -> '1E+9' dqbas147 toSci "1e+90" -> '1E+90' dqbas148 toSci "1E+009" -> '1E+9' dqbas149 toSci "000E+9" -> '0E+9' dqbas150 toSci "1E9" -> '1E+9' dqbas151 toSci "1e09" -> '1E+9' dqbas152 toSci "1E90" -> '1E+90' dqbas153 toSci "1E009" -> '1E+9' dqbas154 toSci "0E9" -> '0E+9' dqbas155 toSci "0.000e+0" -> '0.000' dqbas156 toSci "0.000E-1" -> '0.0000' dqbas157 toSci "4E+9" -> '4E+9' dqbas158 toSci "44E+9" -> '4.4E+10' dqbas159 toSci "0.73e-7" -> '7.3E-8' dqbas160 toSci "00E+9" -> '0E+9' dqbas161 toSci "00E-9" -> '0E-9' dqbas162 toSci "10E+9" -> '1.0E+10' dqbas163 toSci "10E+09" -> '1.0E+10' dqbas164 toSci "10e+90" -> '1.0E+91' dqbas165 toSci "10E+009" -> '1.0E+10' dqbas166 toSci "100e+9" -> '1.00E+11' dqbas167 toSci "100e+09" -> '1.00E+11' dqbas168 toSci "100E+90" -> '1.00E+92' dqbas169 toSci "100e+009" -> '1.00E+11' dqbas170 toSci "1.265" -> '1.265' dqbas171 toSci "1.265E-20" -> '1.265E-20' dqbas172 toSci "1.265E-8" -> '1.265E-8' dqbas173 toSci "1.265E-4" -> '0.0001265' dqbas174 toSci "1.265E-3" -> '0.001265' dqbas175 toSci "1.265E-2" -> '0.01265' dqbas176 toSci "1.265E-1" -> '0.1265' dqbas177 toSci "1.265E-0" -> '1.265' dqbas178 toSci "1.265E+1" -> '12.65' dqbas179 toSci "1.265E+2" -> '126.5' dqbas180 toSci "1.265E+3" -> '1265' dqbas181 toSci "1.265E+4" -> '1.265E+4' dqbas182 toSci "1.265E+8" -> '1.265E+8' dqbas183 toSci "1.265E+20" -> '1.265E+20' dqbas190 toSci "12.65" -> '12.65' dqbas191 toSci "12.65E-20" -> '1.265E-19' dqbas192 toSci "12.65E-8" -> '1.265E-7' dqbas193 toSci "12.65E-4" -> '0.001265' dqbas194 toSci "12.65E-3" -> '0.01265' dqbas195 toSci "12.65E-2" -> '0.1265' dqbas196 toSci "12.65E-1" -> '1.265' dqbas197 toSci "12.65E-0" -> '12.65' dqbas198 toSci "12.65E+1" -> '126.5' dqbas199 toSci "12.65E+2" -> '1265' dqbas200 toSci "12.65E+3" -> '1.265E+4' dqbas201 toSci "12.65E+4" -> '1.265E+5' dqbas202 toSci "12.65E+8" -> '1.265E+9' dqbas203 toSci "12.65E+20" -> '1.265E+21' dqbas210 toSci "126.5" -> '126.5' dqbas211 toSci "126.5E-20" -> '1.265E-18' dqbas212 toSci "126.5E-8" -> '0.000001265' dqbas213 toSci "126.5E-4" -> '0.01265' dqbas214 toSci "126.5E-3" -> '0.1265' dqbas215 toSci "126.5E-2" -> '1.265' dqbas216 toSci "126.5E-1" -> '12.65' dqbas217 toSci "126.5E-0" -> '126.5' dqbas218 toSci "126.5E+1" -> '1265' dqbas219 toSci "126.5E+2" -> '1.265E+4' dqbas220 toSci "126.5E+3" -> '1.265E+5' dqbas221 toSci "126.5E+4" -> '1.265E+6' dqbas222 toSci "126.5E+8" -> '1.265E+10' dqbas223 toSci "126.5E+20" -> '1.265E+22' dqbas230 toSci "1265" -> '1265' dqbas231 toSci "1265E-20" -> '1.265E-17' dqbas232 toSci "1265E-8" -> '0.00001265' dqbas233 toSci "1265E-4" -> '0.1265' dqbas234 toSci "1265E-3" -> '1.265' dqbas235 toSci "1265E-2" -> '12.65' dqbas236 toSci "1265E-1" -> '126.5' dqbas237 toSci "1265E-0" -> '1265' dqbas238 toSci "1265E+1" -> '1.265E+4' dqbas239 toSci "1265E+2" -> '1.265E+5' dqbas240 toSci "1265E+3" -> '1.265E+6' dqbas241 toSci "1265E+4" -> '1.265E+7' dqbas242 toSci "1265E+8" -> '1.265E+11' dqbas243 toSci "1265E+20" -> '1.265E+23' dqbas250 toSci "0.1265" -> '0.1265' dqbas251 toSci "0.1265E-20" -> '1.265E-21' dqbas252 toSci "0.1265E-8" -> '1.265E-9' dqbas253 toSci "0.1265E-4" -> '0.00001265' dqbas254 toSci "0.1265E-3" -> '0.0001265' dqbas255 toSci "0.1265E-2" -> '0.001265' dqbas256 toSci "0.1265E-1" -> '0.01265' dqbas257 toSci "0.1265E-0" -> '0.1265' dqbas258 toSci "0.1265E+1" -> '1.265' dqbas259 toSci "0.1265E+2" -> '12.65' dqbas260 toSci "0.1265E+3" -> '126.5' dqbas261 toSci "0.1265E+4" -> '1265' dqbas262 toSci "0.1265E+8" -> '1.265E+7' dqbas263 toSci "0.1265E+20" -> '1.265E+19' -- some more negative zeros [systematic tests below] dqbas290 toSci "-0.000E-1" -> '-0.0000' dqbas291 toSci "-0.000E-2" -> '-0.00000' dqbas292 toSci "-0.000E-3" -> '-0.000000' dqbas293 toSci "-0.000E-4" -> '-0E-7' dqbas294 toSci "-0.00E-2" -> '-0.0000' dqbas295 toSci "-0.00E-3" -> '-0.00000' dqbas296 toSci "-0.0E-2" -> '-0.000' dqbas297 toSci "-0.0E-3" -> '-0.0000' dqbas298 toSci "-0E-2" -> '-0.00' dqbas299 toSci "-0E-3" -> '-0.000' -- Engineering notation tests dqbas301 toSci 10e12 -> 1.0E+13 dqbas302 toEng 10e12 -> 10E+12 dqbas303 toSci 10e11 -> 1.0E+12 dqbas304 toEng 10e11 -> 1.0E+12 dqbas305 toSci 10e10 -> 1.0E+11 dqbas306 toEng 10e10 -> 100E+9 dqbas307 toSci 10e9 -> 1.0E+10 dqbas308 toEng 10e9 -> 10E+9 dqbas309 toSci 10e8 -> 1.0E+9 dqbas310 toEng 10e8 -> 1.0E+9 dqbas311 toSci 10e7 -> 1.0E+8 dqbas312 toEng 10e7 -> 100E+6 dqbas313 toSci 10e6 -> 1.0E+7 dqbas314 toEng 10e6 -> 10E+6 dqbas315 toSci 10e5 -> 1.0E+6 dqbas316 toEng 10e5 -> 1.0E+6 dqbas317 toSci 10e4 -> 1.0E+5 dqbas318 toEng 10e4 -> 100E+3 dqbas319 toSci 10e3 -> 1.0E+4 dqbas320 toEng 10e3 -> 10E+3 dqbas321 toSci 10e2 -> 1.0E+3 dqbas322 toEng 10e2 -> 1.0E+3 dqbas323 toSci 10e1 -> 1.0E+2 dqbas324 toEng 10e1 -> 100 dqbas325 toSci 10e0 -> 10 dqbas326 toEng 10e0 -> 10 dqbas327 toSci 10e-1 -> 1.0 dqbas328 toEng 10e-1 -> 1.0 dqbas329 toSci 10e-2 -> 0.10 dqbas330 toEng 10e-2 -> 0.10 dqbas331 toSci 10e-3 -> 0.010 dqbas332 toEng 10e-3 -> 0.010 dqbas333 toSci 10e-4 -> 0.0010 dqbas334 toEng 10e-4 -> 0.0010 dqbas335 toSci 10e-5 -> 0.00010 dqbas336 toEng 10e-5 -> 0.00010 dqbas337 toSci 10e-6 -> 0.000010 dqbas338 toEng 10e-6 -> 0.000010 dqbas339 toSci 10e-7 -> 0.0000010 dqbas340 toEng 10e-7 -> 0.0000010 dqbas341 toSci 10e-8 -> 1.0E-7 dqbas342 toEng 10e-8 -> 100E-9 dqbas343 toSci 10e-9 -> 1.0E-8 dqbas344 toEng 10e-9 -> 10E-9 dqbas345 toSci 10e-10 -> 1.0E-9 dqbas346 toEng 10e-10 -> 1.0E-9 dqbas347 toSci 10e-11 -> 1.0E-10 dqbas348 toEng 10e-11 -> 100E-12 dqbas349 toSci 10e-12 -> 1.0E-11 dqbas350 toEng 10e-12 -> 10E-12Loading ...