1------------------------------------------------------------------------
2-- tointegralx.decTest -- round decimal to integral value, exact      --
3-- Copyright (c) Mike Cowlishaw,  1981, 2010.  All rights reserved.   --
4-- Parts copyright (c) IBM Corporation, 1981, 2008.                   --
5------------------------------------------------------------------------
6-- Please see the document "General Decimal Arithmetic Testcases"     --
7-- at http://speleotrove.com/decimal for the description of           --
8-- these testcases.                                                   --
9--                                                                    --
10-- These testcases are experimental ('beta' versions), and they       --
11-- may contain errors.  They are offered on an as-is basis.  In       --
12-- particular, achieving the same results as the tests here is not    --
13-- a guarantee that an implementation complies with any Standard      --
14-- or specification.  The tests are not exhaustive.                   --
15--                                                                    --
16-- Please send comments, suggestions, and corrections to the author:  --
17--   Mike Cowlishaw, mfc@speleotrove.com                              --
18------------------------------------------------------------------------
19version: 2.62
20
21-- This set of tests tests the extended specification 'round-to-integral
22-- value' operation (from IEEE 854, later modified in 754r).
23-- All non-zero results are defined as being those from either copy or
24-- quantize, so those are assumed to have been tested.
25
26-- This tests toIntegraExact, which may set Inexact
27
28extended:    1
29precision:   9
30rounding:    half_up
31maxExponent: 999
32minExponent: -999
33
34intxx001 tointegralx      0     ->  0
35intxx002 tointegralx      0.0   ->  0
36intxx003 tointegralx      0.1   ->  0 Inexact Rounded
37intxx004 tointegralx      0.2   ->  0 Inexact Rounded
38intxx005 tointegralx      0.3   ->  0 Inexact Rounded
39intxx006 tointegralx      0.4   ->  0 Inexact Rounded
40intxx007 tointegralx      0.5   ->  1 Inexact Rounded
41intxx008 tointegralx      0.6   ->  1 Inexact Rounded
42intxx009 tointegralx      0.7   ->  1 Inexact Rounded
43intxx010 tointegralx      0.8   ->  1 Inexact Rounded
44intxx011 tointegralx      0.9   ->  1 Inexact Rounded
45intxx012 tointegralx      1     ->  1
46intxx013 tointegralx      1.0   ->  1 Rounded
47intxx014 tointegralx      1.1   ->  1 Inexact Rounded
48intxx015 tointegralx      1.2   ->  1 Inexact Rounded
49intxx016 tointegralx      1.3   ->  1 Inexact Rounded
50intxx017 tointegralx      1.4   ->  1 Inexact Rounded
51intxx018 tointegralx      1.5   ->  2 Inexact Rounded
52intxx019 tointegralx      1.6   ->  2 Inexact Rounded
53intxx020 tointegralx      1.7   ->  2 Inexact Rounded
54intxx021 tointegralx      1.8   ->  2 Inexact Rounded
55intxx022 tointegralx      1.9   ->  2 Inexact Rounded
56-- negatives
57intxx031 tointegralx     -0     -> -0
58intxx032 tointegralx     -0.0   -> -0
59intxx033 tointegralx     -0.1   -> -0 Inexact Rounded
60intxx034 tointegralx     -0.2   -> -0 Inexact Rounded
61intxx035 tointegralx     -0.3   -> -0 Inexact Rounded
62intxx036 tointegralx     -0.4   -> -0 Inexact Rounded
63intxx037 tointegralx     -0.5   -> -1 Inexact Rounded
64intxx038 tointegralx     -0.6   -> -1 Inexact Rounded
65intxx039 tointegralx     -0.7   -> -1 Inexact Rounded
66intxx040 tointegralx     -0.8   -> -1 Inexact Rounded
67intxx041 tointegralx     -0.9   -> -1 Inexact Rounded
68intxx042 tointegralx     -1     -> -1
69intxx043 tointegralx     -1.0   -> -1 Rounded
70intxx044 tointegralx     -1.1   -> -1 Inexact Rounded
71intxx045 tointegralx     -1.2   -> -1 Inexact Rounded
72intxx046 tointegralx     -1.3   -> -1 Inexact Rounded
73intxx047 tointegralx     -1.4   -> -1 Inexact Rounded
74intxx048 tointegralx     -1.5   -> -2 Inexact Rounded
75intxx049 tointegralx     -1.6   -> -2 Inexact Rounded
76intxx050 tointegralx     -1.7   -> -2 Inexact Rounded
77intxx051 tointegralx     -1.8   -> -2 Inexact Rounded
78intxx052 tointegralx     -1.9   -> -2 Inexact Rounded
79-- next two would be NaN using quantize(x, 0)
80intxx053 tointegralx    10E+30  -> 1.0E+31
81intxx054 tointegralx   -10E+30  -> -1.0E+31
82
83-- numbers around precision
84precision: 9
85intxx060 tointegralx '56267E-10'   -> '0'               Inexact Rounded
86intxx061 tointegralx '56267E-5'    -> '1'               Inexact Rounded
87intxx062 tointegralx '56267E-2'    -> '563'             Inexact Rounded
88intxx063 tointegralx '56267E-1'    -> '5627'            Inexact Rounded
89intxx065 tointegralx '56267E-0'    -> '56267'
90intxx066 tointegralx '56267E+0'    -> '56267'
91intxx067 tointegralx '56267E+1'    -> '5.6267E+5'
92intxx068 tointegralx '56267E+2'    -> '5.6267E+6'
93intxx069 tointegralx '56267E+3'    -> '5.6267E+7'
94intxx070 tointegralx '56267E+4'    -> '5.6267E+8'
95intxx071 tointegralx '56267E+5'    -> '5.6267E+9'
96intxx072 tointegralx '56267E+6'    -> '5.6267E+10'
97intxx073 tointegralx '1.23E+96'    -> '1.23E+96'
98intxx074 tointegralx '1.23E+384'   -> '1.23E+384'
99intxx075 tointegralx '1.23E+999'   -> '1.23E+999'
100
101intxx080 tointegralx '-56267E-10'  -> '-0'              Inexact Rounded
102intxx081 tointegralx '-56267E-5'   -> '-1'              Inexact Rounded
103intxx082 tointegralx '-56267E-2'   -> '-563'            Inexact Rounded
104intxx083 tointegralx '-56267E-1'   -> '-5627'           Inexact Rounded
105intxx085 tointegralx '-56267E-0'   -> '-56267'
106intxx086 tointegralx '-56267E+0'   -> '-56267'
107intxx087 tointegralx '-56267E+1'   -> '-5.6267E+5'
108intxx088 tointegralx '-56267E+2'   -> '-5.6267E+6'
109intxx089 tointegralx '-56267E+3'   -> '-5.6267E+7'
110intxx090 tointegralx '-56267E+4'   -> '-5.6267E+8'
111intxx091 tointegralx '-56267E+5'   -> '-5.6267E+9'
112intxx092 tointegralx '-56267E+6'   -> '-5.6267E+10'
113intxx093 tointegralx '-1.23E+96'   -> '-1.23E+96'
114intxx094 tointegralx '-1.23E+384'  -> '-1.23E+384'
115intxx095 tointegralx '-1.23E+999'  -> '-1.23E+999'
116
117-- subnormal inputs
118intxx100 tointegralx        1E-999 -> 0                 Inexact Rounded
119intxx101 tointegralx      0.1E-999 -> 0                 Inexact Rounded
120intxx102 tointegralx     0.01E-999 -> 0                 Inexact Rounded
121intxx103 tointegralx        0E-999 -> 0
122
123-- specials and zeros
124intxx120 tointegralx 'Inf'       ->  Infinity
125intxx121 tointegralx '-Inf'      -> -Infinity
126intxx122 tointegralx   NaN       ->  NaN
127intxx123 tointegralx  sNaN       ->  NaN  Invalid_operation
128intxx124 tointegralx     0       ->  0
129intxx125 tointegralx    -0       -> -0
130intxx126 tointegralx     0.000   ->  0
131intxx127 tointegralx     0.00    ->  0
132intxx128 tointegralx     0.0     ->  0
133intxx129 tointegralx     0       ->  0
134intxx130 tointegralx     0E-3    ->  0
135intxx131 tointegralx     0E-2    ->  0
136intxx132 tointegralx     0E-1    ->  0
137intxx133 tointegralx     0E-0    ->  0
138intxx134 tointegralx     0E+1    ->  0E+1
139intxx135 tointegralx     0E+2    ->  0E+2
140intxx136 tointegralx     0E+3    ->  0E+3
141intxx137 tointegralx     0E+4    ->  0E+4
142intxx138 tointegralx     0E+5    ->  0E+5
143intxx139 tointegralx    -0.000   -> -0
144intxx140 tointegralx    -0.00    -> -0
145intxx141 tointegralx    -0.0     -> -0
146intxx142 tointegralx    -0       -> -0
147intxx143 tointegralx    -0E-3    -> -0
148intxx144 tointegralx    -0E-2    -> -0
149intxx145 tointegralx    -0E-1    -> -0
150intxx146 tointegralx    -0E-0    -> -0
151intxx147 tointegralx    -0E+1    -> -0E+1
152intxx148 tointegralx    -0E+2    -> -0E+2
153intxx149 tointegralx    -0E+3    -> -0E+3
154intxx150 tointegralx    -0E+4    -> -0E+4
155intxx151 tointegralx    -0E+5    -> -0E+5
156-- propagating NaNs
157intxx152 tointegralx   NaN808    ->  NaN808
158intxx153 tointegralx  sNaN080    ->  NaN80  Invalid_operation
159intxx154 tointegralx  -NaN808    -> -NaN808
160intxx155 tointegralx -sNaN080    -> -NaN80  Invalid_operation
161intxx156 tointegralx  -NaN       -> -NaN
162intxx157 tointegralx -sNaN       -> -NaN    Invalid_operation
163
164-- examples
165rounding:    half_up
166precision:   9
167intxx200 tointegralx     2.1    -> 2                    Inexact Rounded
168intxx201 tointegralx   100      -> 100
169intxx202 tointegralx   100.0    -> 100                  Rounded
170intxx203 tointegralx   101.5    -> 102                  Inexact Rounded
171intxx204 tointegralx  -101.5    -> -102                 Inexact Rounded
172intxx205 tointegralx   10E+5    -> 1.0E+6
173intxx206 tointegralx  7.89E+77  -> 7.89E+77
174intxx207 tointegralx   -Inf     -> -Infinity
175
176
177-- all rounding modes
178rounding:    half_even
179
180intxx210 tointegralx     55.5   ->  56   Inexact Rounded
181intxx211 tointegralx     56.5   ->  56   Inexact Rounded
182intxx212 tointegralx     57.5   ->  58   Inexact Rounded
183intxx213 tointegralx    -55.5   -> -56   Inexact Rounded
184intxx214 tointegralx    -56.5   -> -56   Inexact Rounded
185intxx215 tointegralx    -57.5   -> -58   Inexact Rounded
186
187rounding:    half_up
188
189intxx220 tointegralx     55.5   ->  56   Inexact Rounded
190intxx221 tointegralx     56.5   ->  57   Inexact Rounded
191intxx222 tointegralx     57.5   ->  58   Inexact Rounded
192intxx223 tointegralx    -55.5   -> -56   Inexact Rounded
193intxx224 tointegralx    -56.5   -> -57   Inexact Rounded
194intxx225 tointegralx    -57.5   -> -58   Inexact Rounded
195
196rounding:    half_down
197
198intxx230 tointegralx     55.5   ->  55   Inexact Rounded
199intxx231 tointegralx     56.5   ->  56   Inexact Rounded
200intxx232 tointegralx     57.5   ->  57   Inexact Rounded
201intxx233 tointegralx    -55.5   -> -55   Inexact Rounded
202intxx234 tointegralx    -56.5   -> -56   Inexact Rounded
203intxx235 tointegralx    -57.5   -> -57   Inexact Rounded
204
205rounding:    up
206
207intxx240 tointegralx     55.3   ->  56   Inexact Rounded
208intxx241 tointegralx     56.3   ->  57   Inexact Rounded
209intxx242 tointegralx     57.3   ->  58   Inexact Rounded
210intxx243 tointegralx    -55.3   -> -56   Inexact Rounded
211intxx244 tointegralx    -56.3   -> -57   Inexact Rounded
212intxx245 tointegralx    -57.3   -> -58   Inexact Rounded
213
214rounding:    down
215
216intxx250 tointegralx     55.7   ->  55   Inexact Rounded
217intxx251 tointegralx     56.7   ->  56   Inexact Rounded
218intxx252 tointegralx     57.7   ->  57   Inexact Rounded
219intxx253 tointegralx    -55.7   -> -55   Inexact Rounded
220intxx254 tointegralx    -56.7   -> -56   Inexact Rounded
221intxx255 tointegralx    -57.7   -> -57   Inexact Rounded
222
223rounding:    ceiling
224
225intxx260 tointegralx     55.3   ->  56   Inexact Rounded
226intxx261 tointegralx     56.3   ->  57   Inexact Rounded
227intxx262 tointegralx     57.3   ->  58   Inexact Rounded
228intxx263 tointegralx    -55.3   -> -55   Inexact Rounded
229intxx264 tointegralx    -56.3   -> -56   Inexact Rounded
230intxx265 tointegralx    -57.3   -> -57   Inexact Rounded
231
232rounding:    floor
233
234intxx270 tointegralx     55.7   ->  55   Inexact Rounded
235intxx271 tointegralx     56.7   ->  56   Inexact Rounded
236intxx272 tointegralx     57.7   ->  57   Inexact Rounded
237intxx273 tointegralx    -55.7   -> -56   Inexact Rounded
238intxx274 tointegralx    -56.7   -> -57   Inexact Rounded
239intxx275 tointegralx    -57.7   -> -58   Inexact Rounded
240
241-- Int and uInt32 edge values for testing conversions
242precision: 16
243intxx300 tointegralx -2147483646  -> -2147483646
244intxx301 tointegralx -2147483647  -> -2147483647
245intxx302 tointegralx -2147483648  -> -2147483648
246intxx303 tointegralx -2147483649  -> -2147483649
247intxx304 tointegralx  2147483646  ->  2147483646
248intxx305 tointegralx  2147483647  ->  2147483647
249intxx306 tointegralx  2147483648  ->  2147483648
250intxx307 tointegralx  2147483649  ->  2147483649
251intxx308 tointegralx  4294967294  ->  4294967294
252intxx309 tointegralx  4294967295  ->  4294967295
253intxx310 tointegralx  4294967296  ->  4294967296
254intxx311 tointegralx  4294967297  ->  4294967297
255