1------------------------------------------------------------------------
2-- ddReduce.decTest -- remove trailing zeros from a decDouble         --
3-- Copyright (c) IBM Corporation, 2003, 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
22precision:   16
23maxExponent: 384
24minExponent: -383
25extended:    1
26clamp:       1
27rounding:    half_even
28
29ddred001 reduce '1'      -> '1'
30ddred002 reduce '-1'     -> '-1'
31ddred003 reduce '1.00'   -> '1'
32ddred004 reduce '-1.00'  -> '-1'
33ddred005 reduce '0'      -> '0'
34ddred006 reduce '0.00'   -> '0'
35ddred007 reduce '00.0'   -> '0'
36ddred008 reduce '00.00'  -> '0'
37ddred009 reduce '00'     -> '0'
38ddred010 reduce '0E+1'   -> '0'
39ddred011 reduce '0E+5'   -> '0'
40
41ddred012 reduce '-2'     -> '-2'
42ddred013 reduce '2'      -> '2'
43ddred014 reduce '-2.00'  -> '-2'
44ddred015 reduce '2.00'   -> '2'
45ddred016 reduce '-0'     -> '-0'
46ddred017 reduce '-0.00'  -> '-0'
47ddred018 reduce '-00.0'  -> '-0'
48ddred019 reduce '-00.00' -> '-0'
49ddred020 reduce '-00'    -> '-0'
50ddred021 reduce '-0E+5'   -> '-0'
51ddred022 reduce '-0E+1'  -> '-0'
52
53ddred030 reduce '+0.1'            -> '0.1'
54ddred031 reduce '-0.1'            -> '-0.1'
55ddred032 reduce '+0.01'           -> '0.01'
56ddred033 reduce '-0.01'           -> '-0.01'
57ddred034 reduce '+0.001'          -> '0.001'
58ddred035 reduce '-0.001'          -> '-0.001'
59ddred036 reduce '+0.000001'       -> '0.000001'
60ddred037 reduce '-0.000001'       -> '-0.000001'
61ddred038 reduce '+0.000000000001' -> '1E-12'
62ddred039 reduce '-0.000000000001' -> '-1E-12'
63
64ddred041 reduce 1.1        -> 1.1
65ddred042 reduce 1.10       -> 1.1
66ddred043 reduce 1.100      -> 1.1
67ddred044 reduce 1.110      -> 1.11
68ddred045 reduce -1.1       -> -1.1
69ddred046 reduce -1.10      -> -1.1
70ddred047 reduce -1.100     -> -1.1
71ddred048 reduce -1.110     -> -1.11
72ddred049 reduce 9.9        -> 9.9
73ddred050 reduce 9.90       -> 9.9
74ddred051 reduce 9.900      -> 9.9
75ddred052 reduce 9.990      -> 9.99
76ddred053 reduce -9.9       -> -9.9
77ddred054 reduce -9.90      -> -9.9
78ddred055 reduce -9.900     -> -9.9
79ddred056 reduce -9.990     -> -9.99
80
81-- some trailing fractional zeros with zeros in units
82ddred060 reduce  10.0        -> 1E+1
83ddred061 reduce  10.00       -> 1E+1
84ddred062 reduce  100.0       -> 1E+2
85ddred063 reduce  100.00      -> 1E+2
86ddred064 reduce  1.1000E+3   -> 1.1E+3
87ddred065 reduce  1.10000E+3  -> 1.1E+3
88ddred066 reduce -10.0        -> -1E+1
89ddred067 reduce -10.00       -> -1E+1
90ddred068 reduce -100.0       -> -1E+2
91ddred069 reduce -100.00      -> -1E+2
92ddred070 reduce -1.1000E+3   -> -1.1E+3
93ddred071 reduce -1.10000E+3  -> -1.1E+3
94
95-- some insignificant trailing zeros with positive exponent
96ddred080 reduce  10E+1       -> 1E+2
97ddred081 reduce  100E+1      -> 1E+3
98ddred082 reduce  1.0E+2      -> 1E+2
99ddred083 reduce  1.0E+3      -> 1E+3
100ddred084 reduce  1.1E+3      -> 1.1E+3
101ddred085 reduce  1.00E+3     -> 1E+3
102ddred086 reduce  1.10E+3     -> 1.1E+3
103ddred087 reduce -10E+1       -> -1E+2
104ddred088 reduce -100E+1      -> -1E+3
105ddred089 reduce -1.0E+2      -> -1E+2
106ddred090 reduce -1.0E+3      -> -1E+3
107ddred091 reduce -1.1E+3      -> -1.1E+3
108ddred092 reduce -1.00E+3     -> -1E+3
109ddred093 reduce -1.10E+3     -> -1.1E+3
110
111-- some significant trailing zeros, were we to be trimming
112ddred100 reduce  11          -> 11
113ddred101 reduce  10          -> 1E+1
114ddred102 reduce  10.         -> 1E+1
115ddred103 reduce  1.1E+1      -> 11
116ddred104 reduce  1.0E+1      -> 1E+1
117ddred105 reduce  1.10E+2     -> 1.1E+2
118ddred106 reduce  1.00E+2     -> 1E+2
119ddred107 reduce  1.100E+3    -> 1.1E+3
120ddred108 reduce  1.000E+3    -> 1E+3
121ddred109 reduce  1.000000E+6 -> 1E+6
122ddred110 reduce -11          -> -11
123ddred111 reduce -10          -> -1E+1
124ddred112 reduce -10.         -> -1E+1
125ddred113 reduce -1.1E+1      -> -11
126ddred114 reduce -1.0E+1      -> -1E+1
127ddred115 reduce -1.10E+2     -> -1.1E+2
128ddred116 reduce -1.00E+2     -> -1E+2
129ddred117 reduce -1.100E+3    -> -1.1E+3
130ddred118 reduce -1.000E+3    -> -1E+3
131ddred119 reduce -1.00000E+5  -> -1E+5
132ddred120 reduce -1.000000E+6 -> -1E+6
133ddred121 reduce -10.00000E+6 -> -1E+7
134ddred122 reduce -100.0000E+6 -> -1E+8
135ddred123 reduce -1000.000E+6 -> -1E+9
136ddred124 reduce -10000.00E+6 -> -1E+10
137ddred125 reduce -100000.0E+6 -> -1E+11
138ddred126 reduce -1000000.E+6 -> -1E+12
139
140-- examples from decArith
141ddred140 reduce '2.1'     ->  '2.1'
142ddred141 reduce '-2.0'    ->  '-2'
143ddred142 reduce '1.200'   ->  '1.2'
144ddred143 reduce '-120'    ->  '-1.2E+2'
145ddred144 reduce '120.00'  ->  '1.2E+2'
146ddred145 reduce '0.00'    ->  '0'
147
148-- Nmax, Nmin, Ntiny
149-- note origami effect on some of these
150ddred151 reduce  9.999999999999999E+384   -> 9.999999999999999E+384
151ddred152 reduce  9.999999000000000E+380   -> 9.99999900000E+380
152ddred153 reduce  9.999999999990000E+384   -> 9.999999999990000E+384
153ddred154 reduce  1E-383                   -> 1E-383
154ddred155 reduce  1.000000000000000E-383   -> 1E-383
155ddred156 reduce  2.000E-395               -> 2E-395   Subnormal
156ddred157 reduce  1E-398                   -> 1E-398   Subnormal
157
158ddred161 reduce  -1E-398                  -> -1E-398  Subnormal
159ddred162 reduce  -2.000E-395              -> -2E-395  Subnormal
160ddred163 reduce  -1.000000000000000E-383  -> -1E-383
161ddred164 reduce  -1E-383                  -> -1E-383
162ddred165 reduce  -9.999999000000000E+380  -> -9.99999900000E+380
163ddred166 reduce  -9.999999999990000E+384  -> -9.999999999990000E+384
164ddred167 reduce  -9.999999999999990E+384  -> -9.999999999999990E+384
165ddred168 reduce  -9.999999999999999E+384  -> -9.999999999999999E+384
166ddred169 reduce  -9.999999999999990E+384  -> -9.999999999999990E+384
167
168
169-- specials (reduce does not affect payload)
170ddred820 reduce 'Inf'    -> 'Infinity'
171ddred821 reduce '-Inf'   -> '-Infinity'
172ddred822 reduce   NaN    ->  NaN
173ddred823 reduce  sNaN    ->  NaN    Invalid_operation
174ddred824 reduce   NaN101 ->  NaN101
175ddred825 reduce  sNaN010 ->  NaN10  Invalid_operation
176ddred827 reduce  -NaN    -> -NaN
177ddred828 reduce -sNaN    -> -NaN    Invalid_operation
178ddred829 reduce  -NaN101 -> -NaN101
179ddred830 reduce -sNaN010 -> -NaN10  Invalid_operation
180
181-- Null test
182ddred900 reduce  # -> NaN Invalid_operation
183