|
1 ------------------------------------------------------------------------ |
|
2 -- reduce.decTest -- remove trailing zeros -- |
|
3 -- Copyright (c) IBM Corporation, 2003, 2007. 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 ------------------------------------------------------------------------ |
|
20 -- [This used to be called normalize.] |
|
21 |
|
22 version: 2.57 |
|
23 |
|
24 extended: 1 |
|
25 precision: 9 |
|
26 rounding: half_up |
|
27 maxExponent: 999 |
|
28 minexponent: -999 |
|
29 |
|
30 redx001 reduce '1' -> '1' |
|
31 redx002 reduce '-1' -> '-1' |
|
32 redx003 reduce '1.00' -> '1' |
|
33 redx004 reduce '-1.00' -> '-1' |
|
34 redx005 reduce '0' -> '0' |
|
35 redx006 reduce '0.00' -> '0' |
|
36 redx007 reduce '00.0' -> '0' |
|
37 redx008 reduce '00.00' -> '0' |
|
38 redx009 reduce '00' -> '0' |
|
39 redx010 reduce '0E+1' -> '0' |
|
40 redx011 reduce '0E+5' -> '0' |
|
41 |
|
42 redx012 reduce '-2' -> '-2' |
|
43 redx013 reduce '2' -> '2' |
|
44 redx014 reduce '-2.00' -> '-2' |
|
45 redx015 reduce '2.00' -> '2' |
|
46 redx016 reduce '-0' -> '-0' |
|
47 redx017 reduce '-0.00' -> '-0' |
|
48 redx018 reduce '-00.0' -> '-0' |
|
49 redx019 reduce '-00.00' -> '-0' |
|
50 redx020 reduce '-00' -> '-0' |
|
51 redx021 reduce '-0E+5' -> '-0' |
|
52 redx022 reduce '-0E+1' -> '-0' |
|
53 |
|
54 redx030 reduce '+0.1' -> '0.1' |
|
55 redx031 reduce '-0.1' -> '-0.1' |
|
56 redx032 reduce '+0.01' -> '0.01' |
|
57 redx033 reduce '-0.01' -> '-0.01' |
|
58 redx034 reduce '+0.001' -> '0.001' |
|
59 redx035 reduce '-0.001' -> '-0.001' |
|
60 redx036 reduce '+0.000001' -> '0.000001' |
|
61 redx037 reduce '-0.000001' -> '-0.000001' |
|
62 redx038 reduce '+0.000000000001' -> '1E-12' |
|
63 redx039 reduce '-0.000000000001' -> '-1E-12' |
|
64 |
|
65 redx041 reduce 1.1 -> 1.1 |
|
66 redx042 reduce 1.10 -> 1.1 |
|
67 redx043 reduce 1.100 -> 1.1 |
|
68 redx044 reduce 1.110 -> 1.11 |
|
69 redx045 reduce -1.1 -> -1.1 |
|
70 redx046 reduce -1.10 -> -1.1 |
|
71 redx047 reduce -1.100 -> -1.1 |
|
72 redx048 reduce -1.110 -> -1.11 |
|
73 redx049 reduce 9.9 -> 9.9 |
|
74 redx050 reduce 9.90 -> 9.9 |
|
75 redx051 reduce 9.900 -> 9.9 |
|
76 redx052 reduce 9.990 -> 9.99 |
|
77 redx053 reduce -9.9 -> -9.9 |
|
78 redx054 reduce -9.90 -> -9.9 |
|
79 redx055 reduce -9.900 -> -9.9 |
|
80 redx056 reduce -9.990 -> -9.99 |
|
81 |
|
82 -- some trailing fractional zeros with zeros in units |
|
83 redx060 reduce 10.0 -> 1E+1 |
|
84 redx061 reduce 10.00 -> 1E+1 |
|
85 redx062 reduce 100.0 -> 1E+2 |
|
86 redx063 reduce 100.00 -> 1E+2 |
|
87 redx064 reduce 1.1000E+3 -> 1.1E+3 |
|
88 redx065 reduce 1.10000E+3 -> 1.1E+3 |
|
89 redx066 reduce -10.0 -> -1E+1 |
|
90 redx067 reduce -10.00 -> -1E+1 |
|
91 redx068 reduce -100.0 -> -1E+2 |
|
92 redx069 reduce -100.00 -> -1E+2 |
|
93 redx070 reduce -1.1000E+3 -> -1.1E+3 |
|
94 redx071 reduce -1.10000E+3 -> -1.1E+3 |
|
95 |
|
96 -- some insignificant trailing zeros with positive exponent |
|
97 redx080 reduce 10E+1 -> 1E+2 |
|
98 redx081 reduce 100E+1 -> 1E+3 |
|
99 redx082 reduce 1.0E+2 -> 1E+2 |
|
100 redx083 reduce 1.0E+3 -> 1E+3 |
|
101 redx084 reduce 1.1E+3 -> 1.1E+3 |
|
102 redx085 reduce 1.00E+3 -> 1E+3 |
|
103 redx086 reduce 1.10E+3 -> 1.1E+3 |
|
104 redx087 reduce -10E+1 -> -1E+2 |
|
105 redx088 reduce -100E+1 -> -1E+3 |
|
106 redx089 reduce -1.0E+2 -> -1E+2 |
|
107 redx090 reduce -1.0E+3 -> -1E+3 |
|
108 redx091 reduce -1.1E+3 -> -1.1E+3 |
|
109 redx092 reduce -1.00E+3 -> -1E+3 |
|
110 redx093 reduce -1.10E+3 -> -1.1E+3 |
|
111 |
|
112 -- some significant trailing zeros, were we to be trimming |
|
113 redx100 reduce 11 -> 11 |
|
114 redx101 reduce 10 -> 1E+1 |
|
115 redx102 reduce 10. -> 1E+1 |
|
116 redx103 reduce 1.1E+1 -> 11 |
|
117 redx104 reduce 1.0E+1 -> 1E+1 |
|
118 redx105 reduce 1.10E+2 -> 1.1E+2 |
|
119 redx106 reduce 1.00E+2 -> 1E+2 |
|
120 redx107 reduce 1.100E+3 -> 1.1E+3 |
|
121 redx108 reduce 1.000E+3 -> 1E+3 |
|
122 redx109 reduce 1.000000E+6 -> 1E+6 |
|
123 redx110 reduce -11 -> -11 |
|
124 redx111 reduce -10 -> -1E+1 |
|
125 redx112 reduce -10. -> -1E+1 |
|
126 redx113 reduce -1.1E+1 -> -11 |
|
127 redx114 reduce -1.0E+1 -> -1E+1 |
|
128 redx115 reduce -1.10E+2 -> -1.1E+2 |
|
129 redx116 reduce -1.00E+2 -> -1E+2 |
|
130 redx117 reduce -1.100E+3 -> -1.1E+3 |
|
131 redx118 reduce -1.000E+3 -> -1E+3 |
|
132 redx119 reduce -1.00000E+5 -> -1E+5 |
|
133 redx120 reduce -1.000000E+6 -> -1E+6 |
|
134 redx121 reduce -10.00000E+6 -> -1E+7 |
|
135 redx122 reduce -100.0000E+6 -> -1E+8 |
|
136 redx123 reduce -1000.000E+6 -> -1E+9 |
|
137 redx124 reduce -10000.00E+6 -> -1E+10 |
|
138 redx125 reduce -100000.0E+6 -> -1E+11 |
|
139 redx126 reduce -1000000.E+6 -> -1E+12 |
|
140 |
|
141 -- examples from decArith |
|
142 redx140 reduce '2.1' -> '2.1' |
|
143 redx141 reduce '-2.0' -> '-2' |
|
144 redx142 reduce '1.200' -> '1.2' |
|
145 redx143 reduce '-120' -> '-1.2E+2' |
|
146 redx144 reduce '120.00' -> '1.2E+2' |
|
147 redx145 reduce '0.00' -> '0' |
|
148 |
|
149 -- overflow tests |
|
150 maxexponent: 999999999 |
|
151 minexponent: -999999999 |
|
152 precision: 3 |
|
153 redx160 reduce 9.999E+999999999 -> Infinity Inexact Overflow Rounded |
|
154 redx161 reduce -9.999E+999999999 -> -Infinity Inexact Overflow Rounded |
|
155 |
|
156 -- subnormals and underflow |
|
157 precision: 3 |
|
158 maxexponent: 999 |
|
159 minexponent: -999 |
|
160 redx210 reduce 1.00E-999 -> 1E-999 |
|
161 redx211 reduce 0.1E-999 -> 1E-1000 Subnormal |
|
162 redx212 reduce 0.10E-999 -> 1E-1000 Subnormal |
|
163 redx213 reduce 0.100E-999 -> 1E-1000 Subnormal Rounded |
|
164 redx214 reduce 0.01E-999 -> 1E-1001 Subnormal |
|
165 -- next is rounded to Emin |
|
166 redx215 reduce 0.999E-999 -> 1E-999 Inexact Rounded Subnormal Underflow |
|
167 redx216 reduce 0.099E-999 -> 1E-1000 Inexact Rounded Subnormal Underflow |
|
168 redx217 reduce 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow |
|
169 redx218 reduce 0.001E-999 -> 0 Inexact Rounded Subnormal Underflow Clamped |
|
170 redx219 reduce 0.0009E-999 -> 0 Inexact Rounded Subnormal Underflow Clamped |
|
171 redx220 reduce 0.0001E-999 -> 0 Inexact Rounded Subnormal Underflow Clamped |
|
172 |
|
173 redx230 reduce -1.00E-999 -> -1E-999 |
|
174 redx231 reduce -0.1E-999 -> -1E-1000 Subnormal |
|
175 redx232 reduce -0.10E-999 -> -1E-1000 Subnormal |
|
176 redx233 reduce -0.100E-999 -> -1E-1000 Subnormal Rounded |
|
177 redx234 reduce -0.01E-999 -> -1E-1001 Subnormal |
|
178 -- next is rounded to Emin |
|
179 redx235 reduce -0.999E-999 -> -1E-999 Inexact Rounded Subnormal Underflow |
|
180 redx236 reduce -0.099E-999 -> -1E-1000 Inexact Rounded Subnormal Underflow |
|
181 redx237 reduce -0.009E-999 -> -1E-1001 Inexact Rounded Subnormal Underflow |
|
182 redx238 reduce -0.001E-999 -> -0 Inexact Rounded Subnormal Underflow Clamped |
|
183 redx239 reduce -0.0009E-999 -> -0 Inexact Rounded Subnormal Underflow Clamped |
|
184 redx240 reduce -0.0001E-999 -> -0 Inexact Rounded Subnormal Underflow Clamped |
|
185 |
|
186 -- more reshaping |
|
187 precision: 9 |
|
188 redx260 reduce '56260E-10' -> '0.000005626' |
|
189 redx261 reduce '56260E-5' -> '0.5626' |
|
190 redx262 reduce '56260E-2' -> '562.6' |
|
191 redx263 reduce '56260E-1' -> '5626' |
|
192 redx265 reduce '56260E-0' -> '5.626E+4' |
|
193 redx266 reduce '56260E+0' -> '5.626E+4' |
|
194 redx267 reduce '56260E+1' -> '5.626E+5' |
|
195 redx268 reduce '56260E+2' -> '5.626E+6' |
|
196 redx269 reduce '56260E+3' -> '5.626E+7' |
|
197 redx270 reduce '56260E+4' -> '5.626E+8' |
|
198 redx271 reduce '56260E+5' -> '5.626E+9' |
|
199 redx272 reduce '56260E+6' -> '5.626E+10' |
|
200 redx280 reduce '-56260E-10' -> '-0.000005626' |
|
201 redx281 reduce '-56260E-5' -> '-0.5626' |
|
202 redx282 reduce '-56260E-2' -> '-562.6' |
|
203 redx283 reduce '-56260E-1' -> '-5626' |
|
204 redx285 reduce '-56260E-0' -> '-5.626E+4' |
|
205 redx286 reduce '-56260E+0' -> '-5.626E+4' |
|
206 redx287 reduce '-56260E+1' -> '-5.626E+5' |
|
207 redx288 reduce '-56260E+2' -> '-5.626E+6' |
|
208 redx289 reduce '-56260E+3' -> '-5.626E+7' |
|
209 redx290 reduce '-56260E+4' -> '-5.626E+8' |
|
210 redx291 reduce '-56260E+5' -> '-5.626E+9' |
|
211 redx292 reduce '-56260E+6' -> '-5.626E+10' |
|
212 |
|
213 -- FL test |
|
214 precision: 40 |
|
215 redx295 reduce 9892345673.0123456780000000000 -> 9892345673.012345678 |
|
216 |
|
217 -- specials |
|
218 redx820 reduce 'Inf' -> 'Infinity' |
|
219 redx821 reduce '-Inf' -> '-Infinity' |
|
220 redx822 reduce NaN -> NaN |
|
221 redx823 reduce sNaN -> NaN Invalid_operation |
|
222 redx824 reduce NaN101 -> NaN101 |
|
223 redx825 reduce sNaN010 -> NaN10 Invalid_operation |
|
224 redx827 reduce -NaN -> -NaN |
|
225 redx828 reduce -sNaN -> -NaN Invalid_operation |
|
226 redx829 reduce -NaN101 -> -NaN101 |
|
227 redx830 reduce -sNaN010 -> -NaN10 Invalid_operation |
|
228 |
|
229 -- payload decapitate |
|
230 precision: 5 |
|
231 redx62100 reduce sNaN1234567890 -> NaN67890 Invalid_operation |
|
232 |
|
233 -- Null test |
|
234 redx900 reduce # -> NaN Invalid_operation |