1------------------------------------------------------------------------
2-- tointegral.decTest -- round decimal to integral value              --
3-- Copyright (c) IBM Corporation, 2001, 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
22-- This set of tests tests the extended specification 'round-to-integral
23-- value' operation (from IEEE 854, later modified in 754r).
24-- All non-zero results are defined as being those from either copy or
25-- quantize, so those are assumed to have been tested.
26-- Note that 754r requires that Inexact not be set, and we similarly
27-- assume Rounded is not set.
28
29extended:    1
30precision:   9
31rounding:    half_up
32maxExponent: 999
33minExponent: -999
34
35intx001 tointegral      0     ->  0
36intx002 tointegral      0.0   ->  0
37intx003 tointegral      0.1   ->  0
38intx004 tointegral      0.2   ->  0
39intx005 tointegral      0.3   ->  0
40intx006 tointegral      0.4   ->  0
41intx007 tointegral      0.5   ->  1
42intx008 tointegral      0.6   ->  1
43intx009 tointegral      0.7   ->  1
44intx010 tointegral      0.8   ->  1
45intx011 tointegral      0.9   ->  1
46intx012 tointegral      1     ->  1
47intx013 tointegral      1.0   ->  1
48intx014 tointegral      1.1   ->  1
49intx015 tointegral      1.2   ->  1
50intx016 tointegral      1.3   ->  1
51intx017 tointegral      1.4   ->  1
52intx018 tointegral      1.5   ->  2
53intx019 tointegral      1.6   ->  2
54intx020 tointegral      1.7   ->  2
55intx021 tointegral      1.8   ->  2
56intx022 tointegral      1.9   ->  2
57-- negatives
58intx031 tointegral     -0     -> -0
59intx032 tointegral     -0.0   -> -0
60intx033 tointegral     -0.1   -> -0
61intx034 tointegral     -0.2   -> -0
62intx035 tointegral     -0.3   -> -0
63intx036 tointegral     -0.4   -> -0
64intx037 tointegral     -0.5   -> -1
65intx038 tointegral     -0.6   -> -1
66intx039 tointegral     -0.7   -> -1
67intx040 tointegral     -0.8   -> -1
68intx041 tointegral     -0.9   -> -1
69intx042 tointegral     -1     -> -1
70intx043 tointegral     -1.0   -> -1
71intx044 tointegral     -1.1   -> -1
72intx045 tointegral     -1.2   -> -1
73intx046 tointegral     -1.3   -> -1
74intx047 tointegral     -1.4   -> -1
75intx048 tointegral     -1.5   -> -2
76intx049 tointegral     -1.6   -> -2
77intx050 tointegral     -1.7   -> -2
78intx051 tointegral     -1.8   -> -2
79intx052 tointegral     -1.9   -> -2
80-- next two would be NaN using quantize(x, 0)
81intx053 tointegral    10E+30  -> 1.0E+31
82intx054 tointegral   -10E+30  -> -1.0E+31
83
84-- numbers around precision
85precision: 9
86intx060 tointegral '56267E-10'   -> '0'
87intx061 tointegral '56267E-5'    -> '1'
88intx062 tointegral '56267E-2'    -> '563'
89intx063 tointegral '56267E-1'    -> '5627'
90intx065 tointegral '56267E-0'    -> '56267'
91intx066 tointegral '56267E+0'    -> '56267'
92intx067 tointegral '56267E+1'    -> '5.6267E+5'
93intx068 tointegral '56267E+2'    -> '5.6267E+6'
94intx069 tointegral '56267E+3'    -> '5.6267E+7'
95intx070 tointegral '56267E+4'    -> '5.6267E+8'
96intx071 tointegral '56267E+5'    -> '5.6267E+9'
97intx072 tointegral '56267E+6'    -> '5.6267E+10'
98intx073 tointegral '1.23E+96'    -> '1.23E+96'
99intx074 tointegral '1.23E+384'   -> '1.23E+384'
100intx075 tointegral '1.23E+999'   -> '1.23E+999'
101
102intx080 tointegral '-56267E-10'  -> '-0'
103intx081 tointegral '-56267E-5'   -> '-1'
104intx082 tointegral '-56267E-2'   -> '-563'
105intx083 tointegral '-56267E-1'   -> '-5627'
106intx085 tointegral '-56267E-0'   -> '-56267'
107intx086 tointegral '-56267E+0'   -> '-56267'
108intx087 tointegral '-56267E+1'   -> '-5.6267E+5'
109intx088 tointegral '-56267E+2'   -> '-5.6267E+6'
110intx089 tointegral '-56267E+3'   -> '-5.6267E+7'
111intx090 tointegral '-56267E+4'   -> '-5.6267E+8'
112intx091 tointegral '-56267E+5'   -> '-5.6267E+9'
113intx092 tointegral '-56267E+6'   -> '-5.6267E+10'
114intx093 tointegral '-1.23E+96'   -> '-1.23E+96'
115intx094 tointegral '-1.23E+384'  -> '-1.23E+384'
116intx095 tointegral '-1.23E+999'  -> '-1.23E+999'
117
118-- subnormal inputs
119intx100 tointegral        1E-999 -> 0
120intx101 tointegral      0.1E-999 -> 0
121intx102 tointegral     0.01E-999 -> 0
122intx103 tointegral        0E-999 -> 0
123
124-- specials and zeros
125intx120 tointegral 'Inf'       ->  Infinity
126intx121 tointegral '-Inf'      -> -Infinity
127intx122 tointegral   NaN       ->  NaN
128intx123 tointegral  sNaN       ->  NaN  Invalid_operation
129intx124 tointegral     0       ->  0
130intx125 tointegral    -0       -> -0
131intx126 tointegral     0.000   ->  0
132intx127 tointegral     0.00    ->  0
133intx128 tointegral     0.0     ->  0
134intx129 tointegral     0       ->  0
135intx130 tointegral     0E-3    ->  0
136intx131 tointegral     0E-2    ->  0
137intx132 tointegral     0E-1    ->  0
138intx133 tointegral     0E-0    ->  0
139intx134 tointegral     0E+1    ->  0E+1
140intx135 tointegral     0E+2    ->  0E+2
141intx136 tointegral     0E+3    ->  0E+3
142intx137 tointegral     0E+4    ->  0E+4
143intx138 tointegral     0E+5    ->  0E+5
144intx139 tointegral    -0.000   -> -0
145intx140 tointegral    -0.00    -> -0
146intx141 tointegral    -0.0     -> -0
147intx142 tointegral    -0       -> -0
148intx143 tointegral    -0E-3    -> -0
149intx144 tointegral    -0E-2    -> -0
150intx145 tointegral    -0E-1    -> -0
151intx146 tointegral    -0E-0    -> -0
152intx147 tointegral    -0E+1    -> -0E+1
153intx148 tointegral    -0E+2    -> -0E+2
154intx149 tointegral    -0E+3    -> -0E+3
155intx150 tointegral    -0E+4    -> -0E+4
156intx151 tointegral    -0E+5    -> -0E+5
157-- propagating NaNs
158intx152 tointegral   NaN808    ->  NaN808
159intx153 tointegral  sNaN080    ->  NaN80  Invalid_operation
160intx154 tointegral  -NaN808    -> -NaN808
161intx155 tointegral -sNaN080    -> -NaN80  Invalid_operation
162intx156 tointegral  -NaN       -> -NaN
163intx157 tointegral -sNaN       -> -NaN    Invalid_operation
164
165-- examples
166rounding:    half_up
167precision:   9
168intx200 tointegral     2.1    -> 2
169intx201 tointegral   100      -> 100
170intx202 tointegral   100.0    -> 100
171intx203 tointegral   101.5    -> 102
172intx204 tointegral  -101.5    -> -102
173intx205 tointegral   10E+5    -> 1.0E+6
174intx206 tointegral  7.89E+77  -> 7.89E+77
175intx207 tointegral   -Inf     -> -Infinity
176
177
178-- all rounding modes
179rounding:    half_even
180
181intx210 tointegral     55.5   ->  56
182intx211 tointegral     56.5   ->  56
183intx212 tointegral     57.5   ->  58
184intx213 tointegral    -55.5   -> -56
185intx214 tointegral    -56.5   -> -56
186intx215 tointegral    -57.5   -> -58
187
188rounding:    half_up
189
190intx220 tointegral     55.5   ->  56
191intx221 tointegral     56.5   ->  57
192intx222 tointegral     57.5   ->  58
193intx223 tointegral    -55.5   -> -56
194intx224 tointegral    -56.5   -> -57
195intx225 tointegral    -57.5   -> -58
196
197rounding:    half_down
198
199intx230 tointegral     55.5   ->  55
200intx231 tointegral     56.5   ->  56
201intx232 tointegral     57.5   ->  57
202intx233 tointegral    -55.5   -> -55
203intx234 tointegral    -56.5   -> -56
204intx235 tointegral    -57.5   -> -57
205
206rounding:    up
207
208intx240 tointegral     55.3   ->  56
209intx241 tointegral     56.3   ->  57
210intx242 tointegral     57.3   ->  58
211intx243 tointegral    -55.3   -> -56
212intx244 tointegral    -56.3   -> -57
213intx245 tointegral    -57.3   -> -58
214
215rounding:    down
216
217intx250 tointegral     55.7   ->  55
218intx251 tointegral     56.7   ->  56
219intx252 tointegral     57.7   ->  57
220intx253 tointegral    -55.7   -> -55
221intx254 tointegral    -56.7   -> -56
222intx255 tointegral    -57.7   -> -57
223
224rounding:    ceiling
225
226intx260 tointegral     55.3   ->  56
227intx261 tointegral     56.3   ->  57
228intx262 tointegral     57.3   ->  58
229intx263 tointegral    -55.3   -> -55
230intx264 tointegral    -56.3   -> -56
231intx265 tointegral    -57.3   -> -57
232
233rounding:    floor
234
235intx270 tointegral     55.7   ->  55
236intx271 tointegral     56.7   ->  56
237intx272 tointegral     57.7   ->  57
238intx273 tointegral    -55.7   -> -56
239intx274 tointegral    -56.7   -> -57
240intx275 tointegral    -57.7   -> -58
241
242