17db96d56Sopenharmony_ci------------------------------------------------------------------------ 27db96d56Sopenharmony_ci-- inexact.decTest -- decimal inexact and rounded edge cases -- 37db96d56Sopenharmony_ci-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. -- 47db96d56Sopenharmony_ci------------------------------------------------------------------------ 57db96d56Sopenharmony_ci-- Please see the document "General Decimal Arithmetic Testcases" -- 67db96d56Sopenharmony_ci-- at http://www2.hursley.ibm.com/decimal for the description of -- 77db96d56Sopenharmony_ci-- these testcases. -- 87db96d56Sopenharmony_ci-- -- 97db96d56Sopenharmony_ci-- These testcases are experimental ('beta' versions), and they -- 107db96d56Sopenharmony_ci-- may contain errors. They are offered on an as-is basis. In -- 117db96d56Sopenharmony_ci-- particular, achieving the same results as the tests here is not -- 127db96d56Sopenharmony_ci-- a guarantee that an implementation complies with any Standard -- 137db96d56Sopenharmony_ci-- or specification. The tests are not exhaustive. -- 147db96d56Sopenharmony_ci-- -- 157db96d56Sopenharmony_ci-- Please send comments, suggestions, and corrections to the author: -- 167db96d56Sopenharmony_ci-- Mike Cowlishaw, IBM Fellow -- 177db96d56Sopenharmony_ci-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK -- 187db96d56Sopenharmony_ci-- mfc@uk.ibm.com -- 197db96d56Sopenharmony_ci------------------------------------------------------------------------ 207db96d56Sopenharmony_civersion: 2.59 217db96d56Sopenharmony_ci 227db96d56Sopenharmony_ciextended: 1 237db96d56Sopenharmony_ciprecision: 9 247db96d56Sopenharmony_cirounding: half_up 257db96d56Sopenharmony_cimaxExponent: 999 267db96d56Sopenharmony_ciminexponent: -999 277db96d56Sopenharmony_ci 287db96d56Sopenharmony_ciinx001 add 1 1 -> 2 297db96d56Sopenharmony_ciinx002 add 123456789 0 -> 123456789 307db96d56Sopenharmony_ciinx003 add 123456789 0.0 -> 123456789 Rounded 317db96d56Sopenharmony_ciinx004 add 123456789 0.00 -> 123456789 Rounded 327db96d56Sopenharmony_ciinx005 add 123456789 1 -> 123456790 337db96d56Sopenharmony_ciinx006 add 123456789 0.1 -> 123456789 Inexact Rounded 347db96d56Sopenharmony_ciinx007 add 123456789 0.01 -> 123456789 Inexact Rounded 357db96d56Sopenharmony_ciinx008 add 123456789 0.001 -> 123456789 Inexact Rounded 367db96d56Sopenharmony_ciinx009 add 123456789 0.000001 -> 123456789 Inexact Rounded 377db96d56Sopenharmony_ciinx010 add 123456789 0.000000001 -> 123456789 Inexact Rounded 387db96d56Sopenharmony_ciinx011 add 123456789 0.000000000001 -> 123456789 Inexact Rounded 397db96d56Sopenharmony_ci 407db96d56Sopenharmony_ciinx012 add 123456789 0.9 -> 123456790 Inexact Rounded 417db96d56Sopenharmony_ciinx013 add 123456789 0.09 -> 123456789 Inexact Rounded 427db96d56Sopenharmony_ciinx014 add 123456789 0.009 -> 123456789 Inexact Rounded 437db96d56Sopenharmony_ciinx015 add 123456789 0.000009 -> 123456789 Inexact Rounded 447db96d56Sopenharmony_ciinx016 add 123456789 0.000000009 -> 123456789 Inexact Rounded 457db96d56Sopenharmony_ciinx017 add 123456789 0.000000000009 -> 123456789 Inexact Rounded 467db96d56Sopenharmony_ci 477db96d56Sopenharmony_ciinx021 add 1 -1 -> 0 487db96d56Sopenharmony_ciinx022 add 123456789 -0 -> 123456789 497db96d56Sopenharmony_ciinx023 add 123456789 -0.0 -> 123456789 Rounded 507db96d56Sopenharmony_ciinx024 add 123456789 -0.00 -> 123456789 Rounded 517db96d56Sopenharmony_ciinx025 add 123456789 -1 -> 123456788 527db96d56Sopenharmony_ciinx026 add 123456789 -0.1 -> 123456789 Inexact Rounded 537db96d56Sopenharmony_ciinx027 add 123456789 -0.01 -> 123456789 Inexact Rounded 547db96d56Sopenharmony_ciinx028 add 123456789 -0.001 -> 123456789 Inexact Rounded 557db96d56Sopenharmony_ciinx029 add 123456789 -0.000001 -> 123456789 Inexact Rounded 567db96d56Sopenharmony_ciinx030 add 123456789 -0.000000001 -> 123456789 Inexact Rounded 577db96d56Sopenharmony_ciinx031 add 123456789 -0.000000000001 -> 123456789 Inexact Rounded 587db96d56Sopenharmony_ciinx032 add 123456789 -0.9 -> 123456788 Inexact Rounded 597db96d56Sopenharmony_ciinx033 add 123456789 -0.09 -> 123456789 Inexact Rounded 607db96d56Sopenharmony_ciinx034 add 123456789 -0.009 -> 123456789 Inexact Rounded 617db96d56Sopenharmony_ciinx035 add 123456789 -0.000009 -> 123456789 Inexact Rounded 627db96d56Sopenharmony_ciinx036 add 123456789 -0.000000009 -> 123456789 Inexact Rounded 637db96d56Sopenharmony_ciinx037 add 123456789 -0.000000000009 -> 123456789 Inexact Rounded 647db96d56Sopenharmony_ci 657db96d56Sopenharmony_ciinx042 add 0 123456789 -> 123456789 667db96d56Sopenharmony_ciinx043 add 0.0 123456789 -> 123456789 Rounded 677db96d56Sopenharmony_ciinx044 add 0.00 123456789 -> 123456789 Rounded 687db96d56Sopenharmony_ciinx045 add 1 123456789 -> 123456790 697db96d56Sopenharmony_ciinx046 add 0.1 123456789 -> 123456789 Inexact Rounded 707db96d56Sopenharmony_ciinx047 add 0.01 123456789 -> 123456789 Inexact Rounded 717db96d56Sopenharmony_ciinx048 add 0.001 123456789 -> 123456789 Inexact Rounded 727db96d56Sopenharmony_ciinx049 add 0.000001 123456789 -> 123456789 Inexact Rounded 737db96d56Sopenharmony_ciinx050 add 0.000000001 123456789 -> 123456789 Inexact Rounded 747db96d56Sopenharmony_ciinx051 add 0.000000000001 123456789 -> 123456789 Inexact Rounded 757db96d56Sopenharmony_ciinx052 add 0.9 123456789 -> 123456790 Inexact Rounded 767db96d56Sopenharmony_ciinx053 add 0.09 123456789 -> 123456789 Inexact Rounded 777db96d56Sopenharmony_ciinx054 add 0.009 123456789 -> 123456789 Inexact Rounded 787db96d56Sopenharmony_ciinx055 add 0.000009 123456789 -> 123456789 Inexact Rounded 797db96d56Sopenharmony_ciinx056 add 0.000000009 123456789 -> 123456789 Inexact Rounded 807db96d56Sopenharmony_ciinx057 add 0.000000000009 123456789 -> 123456789 Inexact Rounded 817db96d56Sopenharmony_ci 827db96d56Sopenharmony_ciinx062 add -0 123456789 -> 123456789 837db96d56Sopenharmony_ciinx063 add -0.0 123456789 -> 123456789 Rounded 847db96d56Sopenharmony_ciinx064 add -0.00 123456789 -> 123456789 Rounded 857db96d56Sopenharmony_ciinx065 add -1 123456789 -> 123456788 867db96d56Sopenharmony_ciinx066 add -0.1 123456789 -> 123456789 Inexact Rounded 877db96d56Sopenharmony_ciinx067 add -0.01 123456789 -> 123456789 Inexact Rounded 887db96d56Sopenharmony_ciinx068 add -0.001 123456789 -> 123456789 Inexact Rounded 897db96d56Sopenharmony_ciinx069 add -0.000001 123456789 -> 123456789 Inexact Rounded 907db96d56Sopenharmony_ciinx070 add -0.000000001 123456789 -> 123456789 Inexact Rounded 917db96d56Sopenharmony_ciinx071 add -0.000000000001 123456789 -> 123456789 Inexact Rounded 927db96d56Sopenharmony_ciinx072 add -0.9 123456789 -> 123456788 Inexact Rounded 937db96d56Sopenharmony_ciinx073 add -0.09 123456789 -> 123456789 Inexact Rounded 947db96d56Sopenharmony_ciinx074 add -0.009 123456789 -> 123456789 Inexact Rounded 957db96d56Sopenharmony_ciinx075 add -0.000009 123456789 -> 123456789 Inexact Rounded 967db96d56Sopenharmony_ciinx076 add -0.000000009 123456789 -> 123456789 Inexact Rounded 977db96d56Sopenharmony_ciinx077 add -0.000000000009 123456789 -> 123456789 Inexact Rounded 987db96d56Sopenharmony_ci 997db96d56Sopenharmony_ci-- some boundaries 1007db96d56Sopenharmony_ciinx081 add 999999999 0 -> 999999999 1017db96d56Sopenharmony_ciinx082 add 0.999999999 0.000000000 -> 0.999999999 1027db96d56Sopenharmony_ciinx083 add 999999999 1 -> 1.00000000E+9 Rounded 1037db96d56Sopenharmony_ciinx084 add 0.999999999 0.000000001 -> 1.00000000 Rounded 1047db96d56Sopenharmony_ciinx085 add 999999999 2 -> 1.00000000E+9 Inexact Rounded 1057db96d56Sopenharmony_ciinx086 add 0.999999999 0.000000002 -> 1.00000000 Inexact Rounded 1067db96d56Sopenharmony_ciinx087 add 999999999 3 -> 1.00000000E+9 Inexact Rounded 1077db96d56Sopenharmony_ciinx089 add 0.999999999 0.000000003 -> 1.00000000 Inexact Rounded 1087db96d56Sopenharmony_ci 1097db96d56Sopenharmony_ci-- minus, plus, and subtract all assumed to work like add. 1107db96d56Sopenharmony_ci 1117db96d56Sopenharmony_ci-- multiply 1127db96d56Sopenharmony_ciprecision: 8 1137db96d56Sopenharmony_ciinx101 multiply 1000 1000 -> 1000000 1147db96d56Sopenharmony_ciinx102 multiply 9000 9000 -> 81000000 1157db96d56Sopenharmony_ciinx103 multiply 9999 9999 -> 99980001 1167db96d56Sopenharmony_ciinx104 multiply 1000 10000 -> 10000000 1177db96d56Sopenharmony_ciinx105 multiply 10000 10000 -> 1.0000000E+8 Rounded 1187db96d56Sopenharmony_ciinx106 multiply 10001 10000 -> 1.0001000E+8 Rounded 1197db96d56Sopenharmony_ciinx107 multiply 10001 10001 -> 1.0002000E+8 Inexact Rounded 1207db96d56Sopenharmony_ciinx108 multiply 10101 10001 -> 1.0102010E+8 Inexact Rounded 1217db96d56Sopenharmony_ciinx109 multiply 10001 10101 -> 1.0102010E+8 Inexact Rounded 1227db96d56Sopenharmony_ci 1237db96d56Sopenharmony_ci-- divide 1247db96d56Sopenharmony_ciprecision: 4 1257db96d56Sopenharmony_ciinx201 divide 1000 1000 -> 1 1267db96d56Sopenharmony_ciinx202 divide 1000 1 -> 1000 1277db96d56Sopenharmony_ciinx203 divide 1000 2 -> 500 1287db96d56Sopenharmony_ciinx204 divide 1000 3 -> 333.3 Inexact Rounded 1297db96d56Sopenharmony_ciinx205 divide 1000 4 -> 250 1307db96d56Sopenharmony_ciinx206 divide 1000 5 -> 200 1317db96d56Sopenharmony_ciinx207 divide 1000 6 -> 166.7 Inexact Rounded 1327db96d56Sopenharmony_ciinx208 divide 1000 7 -> 142.9 Inexact Rounded 1337db96d56Sopenharmony_ciinx209 divide 1000 8 -> 125 1347db96d56Sopenharmony_ciinx210 divide 1000 9 -> 111.1 Inexact Rounded 1357db96d56Sopenharmony_ciinx211 divide 1000 10 -> 100 1367db96d56Sopenharmony_ci 1377db96d56Sopenharmony_ciinx220 divide 1 1 -> 1 1387db96d56Sopenharmony_ciinx221 divide 1 2 -> 0.5 1397db96d56Sopenharmony_ciinx222 divide 1 4 -> 0.25 1407db96d56Sopenharmony_ciinx223 divide 1 8 -> 0.125 1417db96d56Sopenharmony_ciinx224 divide 1 16 -> 0.0625 1427db96d56Sopenharmony_ciinx225 divide 1 32 -> 0.03125 1437db96d56Sopenharmony_ciinx226 divide 1 64 -> 0.01563 Inexact Rounded 1447db96d56Sopenharmony_ciinx227 divide 1 128 -> 0.007813 Inexact Rounded 1457db96d56Sopenharmony_ci 1467db96d56Sopenharmony_ciprecision: 5 1477db96d56Sopenharmony_ciinx230 divide 1 1 -> 1 1487db96d56Sopenharmony_ciinx231 divide 1 2 -> 0.5 1497db96d56Sopenharmony_ciinx232 divide 1 4 -> 0.25 1507db96d56Sopenharmony_ciinx233 divide 1 8 -> 0.125 1517db96d56Sopenharmony_ciinx234 divide 1 16 -> 0.0625 1527db96d56Sopenharmony_ciinx235 divide 1 32 -> 0.03125 1537db96d56Sopenharmony_ciinx236 divide 1 64 -> 0.015625 1547db96d56Sopenharmony_ciinx237 divide 1 128 -> 0.0078125 1557db96d56Sopenharmony_ci 1567db96d56Sopenharmony_ciprecision: 3 1577db96d56Sopenharmony_ciinx240 divide 1 1 -> 1 1587db96d56Sopenharmony_ciinx241 divide 1 2 -> 0.5 1597db96d56Sopenharmony_ciinx242 divide 1 4 -> 0.25 1607db96d56Sopenharmony_ciinx243 divide 1 8 -> 0.125 1617db96d56Sopenharmony_ciinx244 divide 1 16 -> 0.0625 1627db96d56Sopenharmony_ciinx245 divide 1 32 -> 0.0313 Inexact Rounded 1637db96d56Sopenharmony_ciinx246 divide 1 64 -> 0.0156 Inexact Rounded 1647db96d56Sopenharmony_ciinx247 divide 1 128 -> 0.00781 Inexact Rounded 1657db96d56Sopenharmony_ci 1667db96d56Sopenharmony_ciprecision: 2 1677db96d56Sopenharmony_ciinx250 divide 1 1 -> 1 1687db96d56Sopenharmony_ciinx251 divide 1 2 -> 0.5 1697db96d56Sopenharmony_ciinx252 divide 1 4 -> 0.25 1707db96d56Sopenharmony_ciinx253 divide 1 8 -> 0.13 Inexact Rounded 1717db96d56Sopenharmony_ciinx254 divide 1 16 -> 0.063 Inexact Rounded 1727db96d56Sopenharmony_ciinx255 divide 1 32 -> 0.031 Inexact Rounded 1737db96d56Sopenharmony_ciinx256 divide 1 64 -> 0.016 Inexact Rounded 1747db96d56Sopenharmony_ciinx257 divide 1 128 -> 0.0078 Inexact Rounded 1757db96d56Sopenharmony_ci 1767db96d56Sopenharmony_ciprecision: 1 1777db96d56Sopenharmony_ciinx260 divide 1 1 -> 1 1787db96d56Sopenharmony_ciinx261 divide 1 2 -> 0.5 1797db96d56Sopenharmony_ciinx262 divide 1 4 -> 0.3 Inexact Rounded 1807db96d56Sopenharmony_ciinx263 divide 1 8 -> 0.1 Inexact Rounded 1817db96d56Sopenharmony_ciinx264 divide 1 16 -> 0.06 Inexact Rounded 1827db96d56Sopenharmony_ciinx265 divide 1 32 -> 0.03 Inexact Rounded 1837db96d56Sopenharmony_ciinx266 divide 1 64 -> 0.02 Inexact Rounded 1847db96d56Sopenharmony_ciinx267 divide 1 128 -> 0.008 Inexact Rounded 1857db96d56Sopenharmony_ci 1867db96d56Sopenharmony_ci 1877db96d56Sopenharmony_ci-- power 1887db96d56Sopenharmony_ciprecision: 4 1897db96d56Sopenharmony_ciinx301 power 0.5 2 -> 0.25 1907db96d56Sopenharmony_ciinx302 power 0.5 4 -> 0.0625 1917db96d56Sopenharmony_ciinx303 power 0.5 8 -> 0.003906 Inexact Rounded 1927db96d56Sopenharmony_ciinx304 power 0.5 16 -> 0.00001526 Inexact Rounded 1937db96d56Sopenharmony_ciinx305 power 0.5 32 -> 2.328E-10 Inexact Rounded 1947db96d56Sopenharmony_ci 1957db96d56Sopenharmony_ci-- compare, divideInteger, and remainder are always exact 1967db96d56Sopenharmony_ci 1977db96d56Sopenharmony_ci-- rescale 1987db96d56Sopenharmony_ciprecision: 4 1997db96d56Sopenharmony_ciinx401 rescale 0 0 -> 0 2007db96d56Sopenharmony_ciinx402 rescale 1 0 -> 1 2017db96d56Sopenharmony_ciinx403 rescale 0.1 +2 -> 0E+2 Inexact Rounded 2027db96d56Sopenharmony_ciinx404 rescale 0.1 +1 -> 0E+1 Inexact Rounded 2037db96d56Sopenharmony_ciinx405 rescale 0.1 0 -> 0 Inexact Rounded 2047db96d56Sopenharmony_ciinx406 rescale 0.1 -1 -> 0.1 2057db96d56Sopenharmony_ciinx407 rescale 0.1 -2 -> 0.10 2067db96d56Sopenharmony_ci 2077db96d56Sopenharmony_ci-- long operands cause rounding too 2087db96d56Sopenharmony_ciprecision: 9 2097db96d56Sopenharmony_ciinx801 plus 123456789 -> 123456789 2107db96d56Sopenharmony_ciinx802 plus 1234567890 -> 1.23456789E+9 Rounded 2117db96d56Sopenharmony_ciinx803 plus 1234567891 -> 1.23456789E+9 Inexact Rounded 2127db96d56Sopenharmony_ciinx804 plus 1234567892 -> 1.23456789E+9 Inexact Rounded 2137db96d56Sopenharmony_ciinx805 plus 1234567899 -> 1.23456790E+9 Inexact Rounded 2147db96d56Sopenharmony_ciinx806 plus 1234567900 -> 1.23456790E+9 Rounded 2157db96d56Sopenharmony_ci 216