Repository URL to install this package:
------------------------------------------------------------------------ -- base.decTest -- base decimal <--> 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 extended: 1 -- This file tests base conversions from string to a decimal number -- and back to a string (in either Scientific or Engineering 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). precision: 16 rounding: half_up maxExponent: 384 minExponent: -383 basx001 toSci 0 -> 0 basx002 toSci 1 -> 1 basx003 toSci 1.0 -> 1.0 basx004 toSci 1.00 -> 1.00 basx005 toSci 10 -> 10 basx006 toSci 1000 -> 1000 basx007 toSci 10.0 -> 10.0 basx008 toSci 10.1 -> 10.1 basx009 toSci 10.4 -> 10.4 basx010 toSci 10.5 -> 10.5 basx011 toSci 10.6 -> 10.6 basx012 toSci 10.9 -> 10.9 basx013 toSci 11.0 -> 11.0 basx014 toSci 1.234 -> 1.234 basx015 toSci 0.123 -> 0.123 basx016 toSci 0.012 -> 0.012 basx017 toSci -0 -> -0 basx018 toSci -0.0 -> -0.0 basx019 toSci -00.00 -> -0.00 basx021 toSci -1 -> -1 basx022 toSci -1.0 -> -1.0 basx023 toSci -0.1 -> -0.1 basx024 toSci -9.1 -> -9.1 basx025 toSci -9.11 -> -9.11 basx026 toSci -9.119 -> -9.119 basx027 toSci -9.999 -> -9.999 basx030 toSci '123456789.123456' -> '123456789.123456' basx031 toSci '123456789.000000' -> '123456789.000000' basx032 toSci '123456789123456' -> '123456789123456' basx033 toSci '0.0000123456789' -> '0.0000123456789' basx034 toSci '0.00000123456789' -> '0.00000123456789' basx035 toSci '0.000000123456789' -> '1.23456789E-7' basx036 toSci '0.0000000123456789' -> '1.23456789E-8' basx037 toSci '0.123456789012344' -> '0.123456789012344' basx038 toSci '0.123456789012345' -> '0.123456789012345' -- String [many more examples are implicitly tested elsewhere] -- strings without E cannot generate E in result basx040 toSci "12" -> '12' basx041 toSci "-76" -> '-76' basx042 toSci "12.76" -> '12.76' basx043 toSci "+12.76" -> '12.76' basx044 toSci "012.76" -> '12.76' basx045 toSci "+0.003" -> '0.003' basx046 toSci "17." -> '17' basx047 toSci ".5" -> '0.5' basx048 toSci "044" -> '44' basx049 toSci "0044" -> '44' basx050 toSci "0.0005" -> '0.0005' basx051 toSci "00.00005" -> '0.00005' basx052 toSci "0.000005" -> '0.000005' basx053 toSci "0.0000050" -> '0.0000050' basx054 toSci "0.0000005" -> '5E-7' basx055 toSci "0.00000005" -> '5E-8' basx056 toSci "12345678.543210" -> '12345678.543210' basx057 toSci "2345678.543210" -> '2345678.543210' basx058 toSci "345678.543210" -> '345678.543210' basx059 toSci "0345678.54321" -> '345678.54321' basx060 toSci "345678.5432" -> '345678.5432' basx061 toSci "+345678.5432" -> '345678.5432' basx062 toSci "+0345678.5432" -> '345678.5432' basx063 toSci "+00345678.5432" -> '345678.5432' basx064 toSci "-345678.5432" -> '-345678.5432' basx065 toSci "-0345678.5432" -> '-345678.5432' basx066 toSci "-00345678.5432" -> '-345678.5432' -- examples basx067 toSci "5E-6" -> '0.000005' basx068 toSci "50E-7" -> '0.0000050' basx069 toSci "5E-7" -> '5E-7' -- [No exotics as no Unicode] -- rounded with dots in all (including edge) places basx071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded basx072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded basx073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded basx074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded basx075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded basx076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded basx077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded basx078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded basx079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded basx080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded basx081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded basx082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded basx083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded basx084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded basx085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded basx086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded basx087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded basx088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded basx089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded basx090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded -- Numbers with E basx130 toSci "0.000E-1" -> '0.0000' basx131 toSci "0.000E-2" -> '0.00000' basx132 toSci "0.000E-3" -> '0.000000' basx133 toSci "0.000E-4" -> '0E-7' basx134 toSci "0.00E-2" -> '0.0000' basx135 toSci "0.00E-3" -> '0.00000' basx136 toSci "0.00E-4" -> '0.000000' basx137 toSci "0.00E-5" -> '0E-7' basx138 toSci "+0E+9" -> '0E+9' basx139 toSci "-0E+9" -> '-0E+9' basx140 toSci "1E+9" -> '1E+9' basx141 toSci "1e+09" -> '1E+9' basx142 toSci "1E+90" -> '1E+90' basx143 toSci "+1E+009" -> '1E+9' basx144 toSci "0E+9" -> '0E+9' basx145 toSci "1E+9" -> '1E+9' basx146 toSci "1E+09" -> '1E+9' basx147 toSci "1e+90" -> '1E+90' basx148 toSci "1E+009" -> '1E+9' basx149 toSci "000E+9" -> '0E+9' basx150 toSci "1E9" -> '1E+9' basx151 toSci "1e09" -> '1E+9' basx152 toSci "1E90" -> '1E+90' basx153 toSci "1E009" -> '1E+9' basx154 toSci "0E9" -> '0E+9' basx155 toSci "0.000e+0" -> '0.000' basx156 toSci "0.000E-1" -> '0.0000' basx157 toSci "4E+9" -> '4E+9' basx158 toSci "44E+9" -> '4.4E+10' basx159 toSci "0.73e-7" -> '7.3E-8' basx160 toSci "00E+9" -> '0E+9' basx161 toSci "00E-9" -> '0E-9' basx162 toSci "10E+9" -> '1.0E+10' basx163 toSci "10E+09" -> '1.0E+10' basx164 toSci "10e+90" -> '1.0E+91' basx165 toSci "10E+009" -> '1.0E+10' basx166 toSci "100e+9" -> '1.00E+11' basx167 toSci "100e+09" -> '1.00E+11' basx168 toSci "100E+90" -> '1.00E+92' basx169 toSci "100e+009" -> '1.00E+11' basx170 toSci "1.265" -> '1.265' basx171 toSci "1.265E-20" -> '1.265E-20' basx172 toSci "1.265E-8" -> '1.265E-8' basx173 toSci "1.265E-4" -> '0.0001265' basx174 toSci "1.265E-3" -> '0.001265' basx175 toSci "1.265E-2" -> '0.01265' basx176 toSci "1.265E-1" -> '0.1265' basx177 toSci "1.265E-0" -> '1.265' basx178 toSci "1.265E+1" -> '12.65' basx179 toSci "1.265E+2" -> '126.5' basx180 toSci "1.265E+3" -> '1265' basx181 toSci "1.265E+4" -> '1.265E+4' basx182 toSci "1.265E+8" -> '1.265E+8' basx183 toSci "1.265E+20" -> '1.265E+20' basx190 toSci "12.65" -> '12.65' basx191 toSci "12.65E-20" -> '1.265E-19' basx192 toSci "12.65E-8" -> '1.265E-7' basx193 toSci "12.65E-4" -> '0.001265' basx194 toSci "12.65E-3" -> '0.01265' basx195 toSci "12.65E-2" -> '0.1265' basx196 toSci "12.65E-1" -> '1.265' basx197 toSci "12.65E-0" -> '12.65' basx198 toSci "12.65E+1" -> '126.5' basx199 toSci "12.65E+2" -> '1265' basx200 toSci "12.65E+3" -> '1.265E+4' basx201 toSci "12.65E+4" -> '1.265E+5' basx202 toSci "12.65E+8" -> '1.265E+9' basx203 toSci "12.65E+20" -> '1.265E+21' basx210 toSci "126.5" -> '126.5' basx211 toSci "126.5E-20" -> '1.265E-18' basx212 toSci "126.5E-8" -> '0.000001265' basx213 toSci "126.5E-4" -> '0.01265' basx214 toSci "126.5E-3" -> '0.1265' basx215 toSci "126.5E-2" -> '1.265' basx216 toSci "126.5E-1" -> '12.65' basx217 toSci "126.5E-0" -> '126.5' basx218 toSci "126.5E+1" -> '1265' basx219 toSci "126.5E+2" -> '1.265E+4' basx220 toSci "126.5E+3" -> '1.265E+5' basx221 toSci "126.5E+4" -> '1.265E+6' basx222 toSci "126.5E+8" -> '1.265E+10' basx223 toSci "126.5E+20" -> '1.265E+22' basx230 toSci "1265" -> '1265' basx231 toSci "1265E-20" -> '1.265E-17' basx232 toSci "1265E-8" -> '0.00001265' basx233 toSci "1265E-4" -> '0.1265' basx234 toSci "1265E-3" -> '1.265' basx235 toSci "1265E-2" -> '12.65' basx236 toSci "1265E-1" -> '126.5' basx237 toSci "1265E-0" -> '1265' basx238 toSci "1265E+1" -> '1.265E+4' basx239 toSci "1265E+2" -> '1.265E+5' basx240 toSci "1265E+3" -> '1.265E+6' basx241 toSci "1265E+4" -> '1.265E+7' basx242 toSci "1265E+8" -> '1.265E+11' basx243 toSci "1265E+20" -> '1.265E+23' basx250 toSci "0.1265" -> '0.1265' basx251 toSci "0.1265E-20" -> '1.265E-21' basx252 toSci "0.1265E-8" -> '1.265E-9' basx253 toSci "0.1265E-4" -> '0.00001265' basx254 toSci "0.1265E-3" -> '0.0001265' basx255 toSci "0.1265E-2" -> '0.001265' basx256 toSci "0.1265E-1" -> '0.01265' basx257 toSci "0.1265E-0" -> '0.1265' basx258 toSci "0.1265E+1" -> '1.265' basx259 toSci "0.1265E+2" -> '12.65' basx260 toSci "0.1265E+3" -> '126.5' basx261 toSci "0.1265E+4" -> '1265' basx262 toSci "0.1265E+8" -> '1.265E+7' basx263 toSci "0.1265E+20" -> '1.265E+19' -- some more negative zeros [systematic tests below] basx290 toSci "-0.000E-1" -> '-0.0000' basx291 toSci "-0.000E-2" -> '-0.00000' basx292 toSci "-0.000E-3" -> '-0.000000' basx293 toSci "-0.000E-4" -> '-0E-7' basx294 toSci "-0.00E-2" -> '-0.0000' basx295 toSci "-0.00E-3" -> '-0.00000' basx296 toSci "-0.0E-2" -> '-0.000' basx297 toSci "-0.0E-3" -> '-0.0000' basx298 toSci "-0E-2" -> '-0.00' basx299 toSci "-0E-3" -> '-0.000' -- Engineering notation tests basx301 toSci 10e12 -> 1.0E+13 basx302 toEng 10e12 -> 10E+12 basx303 toSci 10e11 -> 1.0E+12 basx304 toEng 10e11 -> 1.0E+12 basx305 toSci 10e10 -> 1.0E+11 basx306 toEng 10e10 -> 100E+9 basx307 toSci 10e9 -> 1.0E+10 basx308 toEng 10e9 -> 10E+9 basx309 toSci 10e8 -> 1.0E+9 basx310 toEng 10e8 -> 1.0E+9 basx311 toSci 10e7 -> 1.0E+8 basx312 toEng 10e7 -> 100E+6 basx313 toSci 10e6 -> 1.0E+7 basx314 toEng 10e6 -> 10E+6 basx315 toSci 10e5 -> 1.0E+6 basx316 toEng 10e5 -> 1.0E+6 basx317 toSci 10e4 -> 1.0E+5 basx318 toEng 10e4 -> 100E+3 basx319 toSci 10e3 -> 1.0E+4 basx320 toEng 10e3 -> 10E+3 basx321 toSci 10e2 -> 1.0E+3 basx322 toEng 10e2 -> 1.0E+3 basx323 toSci 10e1 -> 1.0E+2 basx324 toEng 10e1 -> 100 basx325 toSci 10e0 -> 10 basx326 toEng 10e0 -> 10 basx327 toSci 10e-1 -> 1.0 basx328 toEng 10e-1 -> 1.0 basx329 toSci 10e-2 -> 0.10 basx330 toEng 10e-2 -> 0.10 basx331 toSci 10e-3 -> 0.010 basx332 toEng 10e-3 -> 0.010 basx333 toSci 10e-4 -> 0.0010 basx334 toEng 10e-4 -> 0.0010 basx335 toSci 10e-5 -> 0.00010 basx336 toEng 10e-5 -> 0.00010 basx337 toSci 10e-6 -> 0.000010 basx338 toEng 10e-6 -> 0.000010 basx339 toSci 10e-7 -> 0.0000010 basx340 toEng 10e-7 -> 0.0000010 basx341 toSci 10e-8 -> 1.0E-7 basx342 toEng 10e-8 -> 100E-9 basx343 toSci 10e-9 -> 1.0E-8 basx344 toEng 10e-9 -> 10E-9 basx345 toSci 10e-10 -> 1.0E-9 basx346 toEng 10e-10 -> 1.0E-9 basx347 toSci 10e-11 -> 1.0E-10 basx348 toEng 10e-11 -> 100E-12 basx349 toSci 10e-12 -> 1.0E-11 basx350 toEng 10e-12 -> 10E-12 basx351 toSci 10e-13 -> 1.0E-12 basx352 toEng 10e-13 -> 1.0E-12 basx361 toSci 7E12 -> 7E+12 basx362 toEng 7E12 -> 7E+12 basx363 toSci 7E11 -> 7E+11 basx364 toEng 7E11 -> 700E+9 basx365 toSci 7E10 -> 7E+10 basx366 toEng 7E10 -> 70E+9 basx367 toSci 7E9 -> 7E+9 basx368 toEng 7E9 -> 7E+9 basx369 toSci 7E8 -> 7E+8 basx370 toEng 7E8 -> 700E+6 basx371 toSci 7E7 -> 7E+7 basx372 toEng 7E7 -> 70E+6 basx373 toSci 7E6 -> 7E+6 basx374 toEng 7E6 -> 7E+6 basx375 toSci 7E5 -> 7E+5 basx376 toEng 7E5 -> 700E+3 basx377 toSci 7E4 -> 7E+4 basx378 toEng 7E4 -> 70E+3 basx379 toSci 7E3 -> 7E+3 basx380 toEng 7E3 -> 7E+3 basx381 toSci 7E2 -> 7E+2 basx382 toEng 7E2 -> 700 basx383 toSci 7E1 -> 7E+1 basx384 toEng 7E1 -> 70 basx385 toSci 7E0 -> 7 basx386 toEng 7E0 -> 7 basx387 toSci 7E-1 -> 0.7 basx388 toEng 7E-1 -> 0.7 basx389 toSci 7E-2 -> 0.07 basx390 toEng 7E-2 -> 0.07 basx391 toSci 7E-3 -> 0.007Loading ...