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