Home | History | Annotate | Download | only in decimaltestdata
      1 ------------------------------------------------------------------------
      2 -- inexact.decTest -- decimal inexact and rounded edge cases          --
      3 -- Copyright (c) IBM Corporation, 1981, 2008.  All rights reserved.   --
      4 ------------------------------------------------------------------------
      5 -- Please see the document "General Decimal Arithmetic Testcases"     --
      6 -- at http://www2.hursley.ibm.com/decimal for the description of      --
      7 -- these testcases.                                                   --
      8 --                                                                    --
      9 -- These testcases are experimental ('beta' versions), and they       --
     10 -- may contain errors.  They are offered on an as-is basis.  In       --
     11 -- particular, achieving the same results as the tests here is not    --
     12 -- a guarantee that an implementation complies with any Standard      --
     13 -- or specification.  The tests are not exhaustive.                   --
     14 --                                                                    --
     15 -- Please send comments, suggestions, and corrections to the author:  --
     16 --   Mike Cowlishaw, IBM Fellow                                       --
     17 --   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
     18 --   mfc (a] uk.ibm.com                                                   --
     19 ------------------------------------------------------------------------
     20 version: 2.59
     21 
     22 extended:    1
     23 precision:   9
     24 rounding:    half_up
     25 maxExponent: 999
     26 minexponent: -999
     27 
     28 inx001 add 1          1              -> 2
     29 inx002 add 123456789  0              -> 123456789
     30 inx003 add 123456789  0.0            -> 123456789 Rounded
     31 inx004 add 123456789  0.00           -> 123456789 Rounded
     32 inx005 add 123456789  1              -> 123456790
     33 inx006 add 123456789  0.1            -> 123456789 Inexact Rounded
     34 inx007 add 123456789  0.01           -> 123456789 Inexact Rounded
     35 inx008 add 123456789  0.001          -> 123456789 Inexact Rounded
     36 inx009 add 123456789  0.000001       -> 123456789 Inexact Rounded
     37 inx010 add 123456789  0.000000001    -> 123456789 Inexact Rounded
     38 inx011 add 123456789  0.000000000001 -> 123456789 Inexact Rounded
     39 
     40 inx012 add 123456789  0.9            -> 123456790 Inexact Rounded
     41 inx013 add 123456789  0.09           -> 123456789 Inexact Rounded
     42 inx014 add 123456789  0.009          -> 123456789 Inexact Rounded
     43 inx015 add 123456789  0.000009       -> 123456789 Inexact Rounded
     44 inx016 add 123456789  0.000000009    -> 123456789 Inexact Rounded
     45 inx017 add 123456789  0.000000000009 -> 123456789 Inexact Rounded
     46 
     47 inx021 add 1          -1              -> 0
     48 inx022 add 123456789  -0              -> 123456789
     49 inx023 add 123456789  -0.0            -> 123456789 Rounded
     50 inx024 add 123456789  -0.00           -> 123456789 Rounded
     51 inx025 add 123456789  -1              -> 123456788
     52 inx026 add 123456789  -0.1            -> 123456789 Inexact Rounded
     53 inx027 add 123456789  -0.01           -> 123456789 Inexact Rounded
     54 inx028 add 123456789  -0.001          -> 123456789 Inexact Rounded
     55 inx029 add 123456789  -0.000001       -> 123456789 Inexact Rounded
     56 inx030 add 123456789  -0.000000001    -> 123456789 Inexact Rounded
     57 inx031 add 123456789  -0.000000000001 -> 123456789 Inexact Rounded
     58 inx032 add 123456789  -0.9            -> 123456788 Inexact Rounded
     59 inx033 add 123456789  -0.09           -> 123456789 Inexact Rounded
     60 inx034 add 123456789  -0.009          -> 123456789 Inexact Rounded
     61 inx035 add 123456789  -0.000009       -> 123456789 Inexact Rounded
     62 inx036 add 123456789  -0.000000009    -> 123456789 Inexact Rounded
     63 inx037 add 123456789  -0.000000000009 -> 123456789 Inexact Rounded
     64 
     65 inx042 add  0               123456789 -> 123456789
     66 inx043 add  0.0             123456789 -> 123456789 Rounded
     67 inx044 add  0.00            123456789 -> 123456789 Rounded
     68 inx045 add  1               123456789 -> 123456790
     69 inx046 add  0.1             123456789 -> 123456789 Inexact Rounded
     70 inx047 add  0.01            123456789 -> 123456789 Inexact Rounded
     71 inx048 add  0.001           123456789 -> 123456789 Inexact Rounded
     72 inx049 add  0.000001        123456789 -> 123456789 Inexact Rounded
     73 inx050 add  0.000000001     123456789 -> 123456789 Inexact Rounded
     74 inx051 add  0.000000000001  123456789 -> 123456789 Inexact Rounded
     75 inx052 add  0.9             123456789 -> 123456790 Inexact Rounded
     76 inx053 add  0.09            123456789 -> 123456789 Inexact Rounded
     77 inx054 add  0.009           123456789 -> 123456789 Inexact Rounded
     78 inx055 add  0.000009        123456789 -> 123456789 Inexact Rounded
     79 inx056 add  0.000000009     123456789 -> 123456789 Inexact Rounded
     80 inx057 add  0.000000000009  123456789 -> 123456789 Inexact Rounded
     81 
     82 inx062 add  -0              123456789 -> 123456789
     83 inx063 add  -0.0            123456789 -> 123456789 Rounded
     84 inx064 add  -0.00           123456789 -> 123456789 Rounded
     85 inx065 add  -1              123456789 -> 123456788
     86 inx066 add  -0.1            123456789 -> 123456789 Inexact Rounded
     87 inx067 add  -0.01           123456789 -> 123456789 Inexact Rounded
     88 inx068 add  -0.001          123456789 -> 123456789 Inexact Rounded
     89 inx069 add  -0.000001       123456789 -> 123456789 Inexact Rounded
     90 inx070 add  -0.000000001    123456789 -> 123456789 Inexact Rounded
     91 inx071 add  -0.000000000001 123456789 -> 123456789 Inexact Rounded
     92 inx072 add  -0.9            123456789 -> 123456788 Inexact Rounded
     93 inx073 add  -0.09           123456789 -> 123456789 Inexact Rounded
     94 inx074 add  -0.009          123456789 -> 123456789 Inexact Rounded
     95 inx075 add  -0.000009       123456789 -> 123456789 Inexact Rounded
     96 inx076 add  -0.000000009    123456789 -> 123456789 Inexact Rounded
     97 inx077 add  -0.000000000009 123456789 -> 123456789 Inexact Rounded
     98 
     99 -- some boundaries
    100 inx081 add    999999999           0     -> 999999999
    101 inx082 add  0.999999999 0.000000000     -> 0.999999999
    102 inx083 add    999999999           1     -> 1.00000000E+9 Rounded
    103 inx084 add  0.999999999 0.000000001     -> 1.00000000    Rounded
    104 inx085 add    999999999           2     -> 1.00000000E+9 Inexact Rounded
    105 inx086 add  0.999999999 0.000000002     -> 1.00000000    Inexact Rounded
    106 inx087 add    999999999           3     -> 1.00000000E+9 Inexact Rounded
    107 inx089 add  0.999999999 0.000000003     -> 1.00000000    Inexact Rounded
    108 
    109 -- minus, plus, and subtract all assumed to work like add.
    110 
    111 -- multiply
    112 precision: 8
    113 inx101 multiply  1000  1000        ->  1000000
    114 inx102 multiply  9000  9000        -> 81000000
    115 inx103 multiply  9999  9999        -> 99980001
    116 inx104 multiply  1000 10000        -> 10000000
    117 inx105 multiply 10000 10000        -> 1.0000000E+8 Rounded
    118 inx106 multiply 10001 10000        -> 1.0001000E+8 Rounded
    119 inx107 multiply 10001 10001        -> 1.0002000E+8 Inexact Rounded
    120 inx108 multiply 10101 10001        -> 1.0102010E+8 Inexact Rounded
    121 inx109 multiply 10001 10101        -> 1.0102010E+8 Inexact Rounded
    122 
    123 -- divide
    124 precision: 4
    125 inx201 divide  1000  1000        ->  1
    126 inx202 divide  1000     1        ->  1000
    127 inx203 divide  1000     2        ->   500
    128 inx204 divide  1000     3        ->   333.3  Inexact Rounded
    129 inx205 divide  1000     4        ->   250
    130 inx206 divide  1000     5        ->   200
    131 inx207 divide  1000     6        ->   166.7  Inexact Rounded
    132 inx208 divide  1000     7        ->   142.9  Inexact Rounded
    133 inx209 divide  1000     8        ->   125
    134 inx210 divide  1000     9        ->   111.1  Inexact Rounded
    135 inx211 divide  1000    10        ->   100
    136 
    137 inx220 divide     1     1        ->   1
    138 inx221 divide     1     2        ->   0.5
    139 inx222 divide     1     4        ->   0.25
    140 inx223 divide     1     8        ->   0.125
    141 inx224 divide     1    16        ->   0.0625
    142 inx225 divide     1    32        ->   0.03125
    143 inx226 divide     1    64        ->   0.01563  Inexact Rounded
    144 inx227 divide     1   128        ->   0.007813 Inexact Rounded
    145 
    146 precision: 5
    147 inx230 divide     1     1        ->   1
    148 inx231 divide     1     2        ->   0.5
    149 inx232 divide     1     4        ->   0.25
    150 inx233 divide     1     8        ->   0.125
    151 inx234 divide     1    16        ->   0.0625
    152 inx235 divide     1    32        ->   0.03125
    153 inx236 divide     1    64        ->   0.015625
    154 inx237 divide     1   128        ->   0.0078125
    155 
    156 precision: 3
    157 inx240 divide     1     1        ->   1
    158 inx241 divide     1     2        ->   0.5
    159 inx242 divide     1     4        ->   0.25
    160 inx243 divide     1     8        ->   0.125
    161 inx244 divide     1    16        ->   0.0625
    162 inx245 divide     1    32        ->   0.0313   Inexact Rounded
    163 inx246 divide     1    64        ->   0.0156   Inexact Rounded
    164 inx247 divide     1   128        ->   0.00781  Inexact Rounded
    165 
    166 precision: 2
    167 inx250 divide     1     1        ->   1
    168 inx251 divide     1     2        ->   0.5
    169 inx252 divide     1     4        ->   0.25
    170 inx253 divide     1     8        ->   0.13     Inexact Rounded
    171 inx254 divide     1    16        ->   0.063    Inexact Rounded
    172 inx255 divide     1    32        ->   0.031    Inexact Rounded
    173 inx256 divide     1    64        ->   0.016    Inexact Rounded
    174 inx257 divide     1   128        ->   0.0078   Inexact Rounded
    175 
    176 precision: 1
    177 inx260 divide     1     1        ->   1
    178 inx261 divide     1     2        ->   0.5
    179 inx262 divide     1     4        ->   0.3      Inexact Rounded
    180 inx263 divide     1     8        ->   0.1      Inexact Rounded
    181 inx264 divide     1    16        ->   0.06     Inexact Rounded
    182 inx265 divide     1    32        ->   0.03     Inexact Rounded
    183 inx266 divide     1    64        ->   0.02     Inexact Rounded
    184 inx267 divide     1   128        ->   0.008    Inexact Rounded
    185 
    186 
    187 -- power
    188 precision: 4
    189 inx301 power    0.5     2        ->   0.25
    190 inx302 power    0.5     4        ->   0.0625
    191 inx303 power    0.5     8        ->   0.003906   Inexact Rounded
    192 inx304 power    0.5    16        ->   0.00001526 Inexact Rounded
    193 inx305 power    0.5    32        ->   2.328E-10  Inexact Rounded
    194 
    195 -- compare, divideInteger, and remainder are always exact
    196 
    197 -- rescale
    198 precision: 4
    199 inx401 rescale 0       0   -> 0
    200 inx402 rescale 1       0   -> 1
    201 inx403 rescale 0.1    +2   -> 0E+2 Inexact Rounded
    202 inx404 rescale 0.1    +1   -> 0E+1 Inexact Rounded
    203 inx405 rescale 0.1     0   -> 0 Inexact Rounded
    204 inx406 rescale 0.1    -1   -> 0.1
    205 inx407 rescale 0.1    -2   -> 0.10
    206 
    207 -- long operands cause rounding too
    208 precision: 9
    209 inx801 plus  123456789  -> 123456789
    210 inx802 plus  1234567890 -> 1.23456789E+9 Rounded
    211 inx803 plus  1234567891 -> 1.23456789E+9 Inexact Rounded
    212 inx804 plus  1234567892 -> 1.23456789E+9 Inexact Rounded
    213 inx805 plus  1234567899 -> 1.23456790E+9 Inexact Rounded
    214 inx806 plus  1234567900 -> 1.23456790E+9 Rounded
    215 
    216