⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base.dectest

📁 eda is an estimation of distributions algorithm
💻 DECTEST
📖 第 1 页 / 共 4 页
字号:
------------------------------------------------------------------------
-- base.decTest -- base decimal <--> string conversions               --
-- Copyright (c) IBM Corporation, 1981, 2003.  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.15

-- 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:   15
rounding:    half_up
maxExponent: 999999999
extended:    1

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
basx101 toSci "12"        -> '12'
basx102 toSci "-76"       -> '-76'
basx103 toSci "12.76"     -> '12.76'
basx104 toSci "+12.76"    -> '12.76'
basx105 toSci "012.76"    -> '12.76'
basx106 toSci "+0.003"    -> '0.003'
basx107 toSci "17."       -> '17'
basx108 toSci ".5"        -> '0.5'
basx109 toSci "044"       -> '44'
basx110 toSci "0044"      -> '44'
basx111 toSci "0.0005"    -> '0.0005'
basx112 toSci "00.00005"  -> '0.00005'
basx113 toSci "0.000005"  -> '0.000005'
basx114 toSci "0.0000005" -> '5E-7'
basx115 toSci "0.00000005" -> '5E-8'
basx116 toSci "12345678.543210" -> '12345678.543210'
basx117 toSci "2345678.543210" -> '2345678.543210'
basx118 toSci "345678.543210" -> '345678.543210'
basx119 toSci "0345678.54321" -> '345678.54321'
basx120 toSci "345678.5432" -> '345678.5432'
basx121 toSci "+345678.5432" -> '345678.5432'
basx122 toSci "+0345678.5432" -> '345678.5432'
basx123 toSci "+00345678.5432" -> '345678.5432'
basx124 toSci "-345678.5432"  -> '-345678.5432'
basx125 toSci "-0345678.5432"  -> '-345678.5432'
basx126 toSci "-00345678.5432"  -> '-345678.5432'

-- [No exotics as no Unicode]

-- 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'

basx270 toSci "0.09e999"  -> '9E+997'
basx271 toSci "0.9e999"   -> '9E+998'
basx272 toSci "9e999"     -> '9E+999'
basx273 toSci "9.9e999"   -> '9.9E+999'
basx274 toSci "9.99e999"  -> '9.99E+999'
basx275 toSci "9.99e-999" -> '9.99E-999'
basx276 toSci "9.9e-999"  -> '9.9E-999'
basx277 toSci "9e-999"    -> '9E-999'
basx279 toSci "99e-999"   -> '9.9E-998'
basx280 toSci "999e-999"  -> '9.99E-997'
basx281 toSci '0.9e-998'  -> '9E-999'
basx282 toSci '0.09e-997' -> '9E-999'
basx283 toSci '0.1e1000'  -> '1E+999'
basx284 toSci '10e-1000'  -> '1.0E-999'

-- 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -