1------------------------------------------------------------------------
2-- shift.decTest -- shift coefficient left or right                   --
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
28-- Sanity check
29shix001 shift          0    0  ->  0
30shix002 shift          0    2  ->  0
31shix003 shift          1    2  ->  100
32shix004 shift          1    8  ->  100000000
33shix005 shift          1    9  ->  0
34shix006 shift          1   -1  ->  0
35shix007 shift  123456789   -1  ->  12345678
36shix008 shift  123456789   -8  ->  1
37shix009 shift  123456789   -9  ->  0
38shix010 shift          0   -2  ->  0
39
40-- rhs must be an integer
41shix011 shift        1    1.5    -> NaN Invalid_operation
42shix012 shift        1    1.0    -> NaN Invalid_operation
43shix013 shift        1    0.1    -> NaN Invalid_operation
44shix014 shift        1    0.0    -> NaN Invalid_operation
45shix015 shift        1    1E+1   -> NaN Invalid_operation
46shix016 shift        1    1E+99  -> NaN Invalid_operation
47shix017 shift        1    Inf    -> NaN Invalid_operation
48shix018 shift        1    -Inf   -> NaN Invalid_operation
49-- and |rhs| <= precision
50shix020 shift        1    -1000  -> NaN Invalid_operation
51shix021 shift        1    -10    -> NaN Invalid_operation
52shix022 shift        1     10    -> NaN Invalid_operation
53shix023 shift        1     1000  -> NaN Invalid_operation
54
55-- full shifting pattern
56shix030 shift  123456789          -9   -> 0
57shix031 shift  123456789          -8   -> 1
58shix032 shift  123456789          -7   -> 12
59shix033 shift  123456789          -6   -> 123
60shix034 shift  123456789          -5   -> 1234
61shix035 shift  123456789          -4   -> 12345
62shix036 shift  123456789          -3   -> 123456
63shix037 shift  123456789          -2   -> 1234567
64shix038 shift  123456789          -1   -> 12345678
65shix039 shift  123456789          -0   -> 123456789
66shix040 shift  123456789          +0   -> 123456789
67shix041 shift  123456789          +1   -> 234567890
68shix042 shift  123456789          +2   -> 345678900
69shix043 shift  123456789          +3   -> 456789000
70shix044 shift  123456789          +4   -> 567890000
71shix045 shift  123456789          +5   -> 678900000
72shix046 shift  123456789          +6   -> 789000000
73shix047 shift  123456789          +7   -> 890000000
74shix048 shift  123456789          +8   -> 900000000
75shix049 shift  123456789          +9   -> 0
76
77-- from examples
78shix051 shift 34        8   ->  '400000000'
79shix052 shift 12        9   ->  '0'
80shix053 shift 123456789 -2  ->  '1234567'
81shix054 shift 123456789 0   ->  '123456789'
82shix055 shift 123456789 +2  ->  '345678900'
83
84-- zeros
85shix060 shift  0E-10              +9   ->   0E-10
86shix061 shift  0E-10              -9   ->   0E-10
87shix062 shift  0.000              +9   ->   0.000
88shix063 shift  0.000              -9   ->   0.000
89shix064 shift  0E+10              +9   ->   0E+10
90shix065 shift  0E+10              -9   ->   0E+10
91shix066 shift -0E-10              +9   ->  -0E-10
92shix067 shift -0E-10              -9   ->  -0E-10
93shix068 shift -0.000              +9   ->  -0.000
94shix069 shift -0.000              -9   ->  -0.000
95shix070 shift -0E+10              +9   ->  -0E+10
96shix071 shift -0E+10              -9   ->  -0E+10
97
98-- Nmax, Nmin, Ntiny
99shix141 shift  9.99999999E+999     -1  -> 9.9999999E+998
100shix142 shift  9.99999999E+999     -8  -> 9E+991
101shix143 shift  9.99999999E+999      1  -> 9.99999990E+999
102shix144 shift  9.99999999E+999      8  -> 9.00000000E+999
103shix145 shift  1E-999              -1  -> 0E-999
104shix146 shift  1E-999              -8  -> 0E-999
105shix147 shift  1E-999               1  -> 1.0E-998
106shix148 shift  1E-999               8  -> 1.00000000E-991
107shix151 shift  1.00000000E-999     -1  -> 1.0000000E-1000
108shix152 shift  1.00000000E-999     -8  -> 1E-1007
109shix153 shift  1.00000000E-999      1  -> 0E-1007
110shix154 shift  1.00000000E-999      8  -> 0E-1007
111shix155 shift  9.00000000E-999     -1  -> 9.0000000E-1000
112shix156 shift  9.00000000E-999     -8  -> 9E-1007
113shix157 shift  9.00000000E-999      1  -> 0E-1007
114shix158 shift  9.00000000E-999      8  -> 0E-1007
115shix160 shift  1E-1007             -1  -> 0E-1007
116shix161 shift  1E-1007             -8  -> 0E-1007
117shix162 shift  1E-1007              1  -> 1.0E-1006
118shix163 shift  1E-1007              8  -> 1.00000000E-999
119--  negatives
120shix171 shift -9.99999999E+999     -1  -> -9.9999999E+998
121shix172 shift -9.99999999E+999     -8  -> -9E+991
122shix173 shift -9.99999999E+999      1  -> -9.99999990E+999
123shix174 shift -9.99999999E+999      8  -> -9.00000000E+999
124shix175 shift -1E-999              -1  -> -0E-999
125shix176 shift -1E-999              -8  -> -0E-999
126shix177 shift -1E-999               1  -> -1.0E-998
127shix178 shift -1E-999               8  -> -1.00000000E-991
128shix181 shift -1.00000000E-999     -1  -> -1.0000000E-1000
129shix182 shift -1.00000000E-999     -8  -> -1E-1007
130shix183 shift -1.00000000E-999      1  -> -0E-1007
131shix184 shift -1.00000000E-999      8  -> -0E-1007
132shix185 shift -9.00000000E-999     -1  -> -9.0000000E-1000
133shix186 shift -9.00000000E-999     -8  -> -9E-1007
134shix187 shift -9.00000000E-999      1  -> -0E-1007
135shix188 shift -9.00000000E-999      8  -> -0E-1007
136shix190 shift -1E-1007             -1  -> -0E-1007
137shix191 shift -1E-1007             -8  -> -0E-1007
138shix192 shift -1E-1007              1  -> -1.0E-1006
139shix193 shift -1E-1007              8  -> -1.00000000E-999
140
141-- more negatives (of sanities)
142shix201 shift         -0    0  ->  -0
143shix202 shift         -0    2  ->  -0
144shix203 shift         -1    2  ->  -100
145shix204 shift         -1    8  ->  -100000000
146shix205 shift         -1    9  ->  -0
147shix206 shift         -1   -1  ->  -0
148shix207 shift -123456789   -1  ->  -12345678
149shix208 shift -123456789   -8  ->  -1
150shix209 shift -123456789   -9  ->  -0
151shix210 shift         -0   -2  ->  -0
152shix211 shift         -0   -0  ->  -0
153
154
155-- Specials; NaNs are handled as usual
156shix781 shift -Inf  -8     -> -Infinity
157shix782 shift -Inf  -1     -> -Infinity
158shix783 shift -Inf  -0     -> -Infinity
159shix784 shift -Inf   0     -> -Infinity
160shix785 shift -Inf   1     -> -Infinity
161shix786 shift -Inf   8     -> -Infinity
162shix787 shift -1000 -Inf   -> NaN Invalid_operation
163shix788 shift -Inf  -Inf   -> NaN Invalid_operation
164shix789 shift -1    -Inf   -> NaN Invalid_operation
165shix790 shift -0    -Inf   -> NaN Invalid_operation
166shix791 shift  0    -Inf   -> NaN Invalid_operation
167shix792 shift  1    -Inf   -> NaN Invalid_operation
168shix793 shift  1000 -Inf   -> NaN Invalid_operation
169shix794 shift  Inf  -Inf   -> NaN Invalid_operation
170
171shix800 shift  Inf  -Inf   -> NaN Invalid_operation
172shix801 shift  Inf  -8     -> Infinity
173shix802 shift  Inf  -1     -> Infinity
174shix803 shift  Inf  -0     -> Infinity
175shix804 shift  Inf   0     -> Infinity
176shix805 shift  Inf   1     -> Infinity
177shix806 shift  Inf   8     -> Infinity
178shix807 shift  Inf   Inf   -> NaN Invalid_operation
179shix808 shift -1000  Inf   -> NaN Invalid_operation
180shix809 shift -Inf   Inf   -> NaN Invalid_operation
181shix810 shift -1     Inf   -> NaN Invalid_operation
182shix811 shift -0     Inf   -> NaN Invalid_operation
183shix812 shift  0     Inf   -> NaN Invalid_operation
184shix813 shift  1     Inf   -> NaN Invalid_operation
185shix814 shift  1000  Inf   -> NaN Invalid_operation
186shix815 shift  Inf   Inf   -> NaN Invalid_operation
187
188shix821 shift  NaN -Inf    ->  NaN
189shix822 shift  NaN -1000   ->  NaN
190shix823 shift  NaN -1      ->  NaN
191shix824 shift  NaN -0      ->  NaN
192shix825 shift  NaN  0      ->  NaN
193shix826 shift  NaN  1      ->  NaN
194shix827 shift  NaN  1000   ->  NaN
195shix828 shift  NaN  Inf    ->  NaN
196shix829 shift  NaN  NaN    ->  NaN
197shix830 shift -Inf  NaN    ->  NaN
198shix831 shift -1000 NaN    ->  NaN
199shix832 shift -1    NaN    ->  NaN
200shix833 shift -0    NaN    ->  NaN
201shix834 shift  0    NaN    ->  NaN
202shix835 shift  1    NaN    ->  NaN
203shix836 shift  1000 NaN    ->  NaN
204shix837 shift  Inf  NaN    ->  NaN
205
206shix841 shift  sNaN -Inf   ->  NaN  Invalid_operation
207shix842 shift  sNaN -1000  ->  NaN  Invalid_operation
208shix843 shift  sNaN -1     ->  NaN  Invalid_operation
209shix844 shift  sNaN -0     ->  NaN  Invalid_operation
210shix845 shift  sNaN  0     ->  NaN  Invalid_operation
211shix846 shift  sNaN  1     ->  NaN  Invalid_operation
212shix847 shift  sNaN  1000  ->  NaN  Invalid_operation
213shix848 shift  sNaN  NaN   ->  NaN  Invalid_operation
214shix849 shift  sNaN sNaN   ->  NaN  Invalid_operation
215shix850 shift  NaN  sNaN   ->  NaN  Invalid_operation
216shix851 shift -Inf  sNaN   ->  NaN  Invalid_operation
217shix852 shift -1000 sNaN   ->  NaN  Invalid_operation
218shix853 shift -1    sNaN   ->  NaN  Invalid_operation
219shix854 shift -0    sNaN   ->  NaN  Invalid_operation
220shix855 shift  0    sNaN   ->  NaN  Invalid_operation
221shix856 shift  1    sNaN   ->  NaN  Invalid_operation
222shix857 shift  1000 sNaN   ->  NaN  Invalid_operation
223shix858 shift  Inf  sNaN   ->  NaN  Invalid_operation
224shix859 shift  NaN  sNaN   ->  NaN  Invalid_operation
225
226-- propagating NaNs
227shix861 shift  NaN1   -Inf    ->  NaN1
228shix862 shift +NaN2   -1000   ->  NaN2
229shix863 shift  NaN3    1000   ->  NaN3
230shix864 shift  NaN4    Inf    ->  NaN4
231shix865 shift  NaN5   +NaN6   ->  NaN5
232shix866 shift -Inf     NaN7   ->  NaN7
233shix867 shift -1000    NaN8   ->  NaN8
234shix868 shift  1000    NaN9   ->  NaN9
235shix869 shift  Inf    +NaN10  ->  NaN10
236shix871 shift  sNaN11  -Inf   ->  NaN11  Invalid_operation
237shix872 shift  sNaN12  -1000  ->  NaN12  Invalid_operation
238shix873 shift  sNaN13   1000  ->  NaN13  Invalid_operation
239shix874 shift  sNaN14   NaN17 ->  NaN14  Invalid_operation
240shix875 shift  sNaN15  sNaN18 ->  NaN15  Invalid_operation
241shix876 shift  NaN16   sNaN19 ->  NaN19  Invalid_operation
242shix877 shift -Inf    +sNaN20 ->  NaN20  Invalid_operation
243shix878 shift -1000    sNaN21 ->  NaN21  Invalid_operation
244shix879 shift  1000    sNaN22 ->  NaN22  Invalid_operation
245shix880 shift  Inf     sNaN23 ->  NaN23  Invalid_operation
246shix881 shift +NaN25  +sNaN24 ->  NaN24  Invalid_operation
247shix882 shift -NaN26    NaN28 -> -NaN26
248shix883 shift -sNaN27  sNaN29 -> -NaN27  Invalid_operation
249shix884 shift  1000    -NaN30 -> -NaN30
250shix885 shift  1000   -sNaN31 -> -NaN31  Invalid_operation
251