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