Rev 737 | Rev 828 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 737 | Rev 804 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | /* Arithmetic functions */ |
41 | /* Arithmetic functions */ |
42 | 42 | ||
43 | float __addsf3(float a, float b) |
43 | float __addsf3(float a, float b) |
44 | { |
44 | { |
45 | float32 fa, fb; |
45 | float32 fa, fb; |
46 | fa.f=a; |
46 | fa.f = a; |
47 | fb.f=b; |
47 | fb.f = b; |
48 | if (fa.parts.sign!=fb.parts.sign) { |
48 | if (fa.parts.sign != fb.parts.sign) { |
49 | if (fa.parts.sign) { |
49 | if (fa.parts.sign) { |
50 | fa.parts.sign=0; |
50 | fa.parts.sign = 0; |
51 | return subFloat32(fb,fa).f; |
51 | return subFloat32(fb, fa).f; |
52 | }; |
52 | }; |
53 | fb.parts.sign=0; |
53 | fb.parts.sign = 0; |
54 | return subFloat32(fa,fb).f; |
54 | return subFloat32(fa, fb).f; |
55 | } |
55 | } |
56 | return addFloat32(fa,fb).f; |
56 | return addFloat32(fa, fb).f; |
57 | } |
57 | } |
58 | 58 | ||
59 | double __adddf3(double a, double b) |
59 | double __adddf3(double a, double b) |
60 | { |
60 | { |
61 | float64 da, db; |
61 | float64 da, db; |
62 | da.d=a; |
62 | da.d = a; |
63 | db.d=b; |
63 | db.d = b; |
64 | if (da.parts.sign!=db.parts.sign) { |
64 | if (da.parts.sign != db.parts.sign) { |
65 | if (da.parts.sign) { |
65 | if (da.parts.sign) { |
66 | da.parts.sign=0; |
66 | da.parts.sign = 0; |
67 | return subFloat64(db,da).d; |
67 | return subFloat64(db, da).d; |
68 | }; |
68 | }; |
69 | db.parts.sign=0; |
69 | db.parts.sign = 0; |
70 | return subFloat64(da,db).d; |
70 | return subFloat64(da, db).d; |
71 | } |
71 | } |
72 | return addFloat64(da,db).d; |
72 | return addFloat64(da, db).d; |
73 | } |
73 | } |
74 | 74 | ||
75 | float __subsf3(float a, float b) |
75 | float __subsf3(float a, float b) |
76 | { |
76 | { |
77 | float32 fa, fb; |
77 | float32 fa, fb; |
78 | fa.f=a; |
78 | fa.f = a; |
79 | fb.f=b; |
79 | fb.f = b; |
80 | if (fa.parts.sign!=fb.parts.sign) { |
80 | if (fa.parts.sign != fb.parts.sign) { |
81 | fb.parts.sign=!fb.parts.sign; |
81 | fb.parts.sign = !fb.parts.sign; |
82 | return addFloat32(fa,fb).f; |
82 | return addFloat32(fa, fb).f; |
83 | } |
83 | } |
84 | return subFloat32(fa,fb).f; |
84 | return subFloat32(fa, fb).f; |
85 | } |
85 | } |
86 | 86 | ||
87 | double __subdf3(double a, double b) |
87 | double __subdf3(double a, double b) |
88 | { |
88 | { |
89 | float64 da, db; |
89 | float64 da, db; |
Line 97... | Line 97... | ||
97 | } |
97 | } |
98 | 98 | ||
99 | float __mulsf3(float a, float b) |
99 | float __mulsf3(float a, float b) |
100 | { |
100 | { |
101 | float32 fa, fb; |
101 | float32 fa, fb; |
102 | fa.f=a; |
102 | fa.f = a; |
103 | fb.f=b; |
103 | fb.f = b; |
104 | return mulFloat32(fa, fb).f; |
104 | return mulFloat32(fa, fb).f; |
105 | } |
105 | } |
106 | 106 | ||
107 | double __muldf3(double a, double b) |
107 | double __muldf3(double a, double b) |
108 | { |
108 | { |
Line 113... | Line 113... | ||
113 | } |
113 | } |
114 | 114 | ||
115 | float __divsf3(float a, float b) |
115 | float __divsf3(float a, float b) |
116 | { |
116 | { |
117 | float32 fa, fb; |
117 | float32 fa, fb; |
118 | fa.f=a; |
118 | fa.f = a; |
119 | fb.f=b; |
119 | fb.f = b; |
120 | //return divFloat32(fa, fb).f; |
120 | return divFloat32(fa, fb).f; |
121 | } |
121 | } |
122 | 122 | ||
123 | float __negsf2(float a) |
123 | float __negsf2(float a) |
124 | { |
124 | { |
125 | float32 fa; |
125 | float32 fa; |
126 | fa.f=a; |
126 | fa.f = a; |
127 | fa.parts.sign=!fa.parts.sign; |
127 | fa.parts.sign = !fa.parts.sign; |
128 | return fa.f; |
128 | return fa.f; |
129 | } |
129 | } |
130 | 130 | ||
131 | double __negdf2(double a) |
131 | double __negdf2(double a) |
132 | { |
132 | { |
133 | float64 fa; |
133 | float64 fa; |
134 | fa.d=a; |
134 | fa.d = a; |
135 | fa.parts.sign=!fa.parts.sign; |
135 | fa.parts.sign = !fa.parts.sign; |
136 | return fa.d; |
136 | return fa.d; |
137 | } |
137 | } |
138 | 138 | ||
139 | /* Conversion functions */ |
139 | /* Conversion functions */ |
140 | 140 | ||
Line 159... | Line 159... | ||
159 | * a>b .. 1 |
159 | * a>b .. 1 |
160 | * */ |
160 | * */ |
161 | 161 | ||
162 | int __cmpsf2(float a, float b) |
162 | int __cmpsf2(float a, float b) |
163 | { |
163 | { |
164 | float32 fa,fb; |
164 | float32 fa, fb; |
165 | fa.f=a; |
165 | fa.f = a; |
166 | fb.f=b; |
166 | fb.f = b; |
167 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
167 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
168 | return 1; /* no special constant for unordered - maybe signaled? */ |
168 | return 1; /* no special constant for unordered - maybe signaled? */ |
169 | }; |
169 | }; |
170 | 170 | ||
171 | 171 | ||
172 | if (isFloat32eq(fa,fb)) { |
172 | if (isFloat32eq(fa, fb)) { |
173 | return 0; |
173 | return 0; |
174 | }; |
174 | }; |
175 | 175 | ||
176 | if (isFloat32lt(fa,fb)) { |
176 | if (isFloat32lt(fa, fb)) { |
177 | return -1; |
177 | return -1; |
178 | }; |
178 | }; |
179 | return 1; |
179 | return 1; |
180 | } |
180 | } |
181 | 181 | ||
182 | int __unordsf2(float a, float b) |
182 | int __unordsf2(float a, float b) |
183 | { |
183 | { |
184 | float32 fa,fb; |
184 | float32 fa, fb; |
185 | fa.f=a; |
185 | fa.f = a; |
186 | fb.f=b; |
186 | fb.f = b; |
187 | return ((isFloat32NaN(fa))||(isFloat32NaN(fb))); |
187 | return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ); |
188 | } |
188 | } |
189 | 189 | ||
190 | /** |
190 | /** |
191 | * @return zero, if neither argument is a NaN and are equal |
191 | * @return zero, if neither argument is a NaN and are equal |
192 | * */ |
192 | * */ |
193 | int __eqsf2(float a, float b) |
193 | int __eqsf2(float a, float b) |
194 | { |
194 | { |
195 | float32 fa,fb; |
195 | float32 fa, fb; |
196 | fa.f=a; |
196 | fa.f = a; |
197 | fb.f=b; |
197 | fb.f = b; |
198 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
198 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
199 | /* TODO: sigNaNs*/ |
199 | /* TODO: sigNaNs*/ |
200 | return 1; |
200 | return 1; |
201 | }; |
201 | }; |
202 | return isFloat32eq(fa,fb)-1; |
202 | return isFloat32eq(fa, fb) - 1; |
203 | } |
203 | } |
204 | 204 | ||
205 | /* strange behavior, but it was in gcc documentation */ |
205 | /* strange behavior, but it was in gcc documentation */ |
206 | int __nesf2(float a, float b) |
206 | int __nesf2(float a, float b) |
207 | { |
207 | { |
208 | return __eqsf2(a,b); |
208 | return __eqsf2(a, b); |
209 | } |
209 | } |
210 | 210 | ||
211 | /* return value >= 0 if a>=b and neither is NaN */ |
211 | /* return value >= 0 if a>=b and neither is NaN */ |
212 | int __gesf2(float a, float b) |
212 | int __gesf2(float a, float b) |
213 | { |
213 | { |
214 | float32 fa,fb; |
214 | float32 fa, fb; |
215 | fa.f=a; |
215 | fa.f = a; |
216 | fb.f=b; |
216 | fb.f = b; |
217 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
217 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
218 | /* TODO: sigNaNs*/ |
218 | /* TODO: sigNaNs*/ |
219 | return -1; |
219 | return -1; |
220 | }; |
220 | }; |
221 | 221 | ||
222 | if (isFloat32eq(fa,fb)) { |
222 | if (isFloat32eq(fa, fb)) { |
223 | return 0; |
223 | return 0; |
224 | }; |
224 | }; |
225 | 225 | ||
226 | if (isFloat32gt(fa,fb)) { |
226 | if (isFloat32gt(fa, fb)) { |
227 | return 1; |
227 | return 1; |
228 | }; |
228 | }; |
229 | 229 | ||
230 | return -1; |
230 | return -1; |
231 | } |
231 | } |
232 | 232 | ||
233 | /** Return negative value, if a<b and neither is NaN*/ |
233 | /** Return negative value, if a<b and neither is NaN*/ |
234 | int __ltsf2(float a, float b) |
234 | int __ltsf2(float a, float b) |
235 | { |
235 | { |
236 | float32 fa,fb; |
236 | float32 fa, fb; |
237 | fa.f=a; |
237 | fa.f = a; |
238 | fb.f=b; |
238 | fb.f = b; |
239 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
239 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
240 | /* TODO: sigNaNs*/ |
240 | /* TODO: sigNaNs*/ |
241 | return 1; |
241 | return 1; |
242 | }; |
242 | }; |
243 | if (isFloat32lt(fa, fb)) { |
243 | if (isFloat32lt(fa, fb)) { |
244 | return -1; |
244 | return -1; |
Line 247... | Line 247... | ||
247 | } |
247 | } |
248 | 248 | ||
249 | /* return value <= 0 if a<=b and neither is NaN */ |
249 | /* return value <= 0 if a<=b and neither is NaN */ |
250 | int __lesf2(float a, float b) |
250 | int __lesf2(float a, float b) |
251 | { |
251 | { |
252 | float32 fa,fb; |
252 | float32 fa, fb; |
253 | fa.f=a; |
253 | fa.f = a; |
254 | fb.f=b; |
254 | fb.f = b; |
255 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
255 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
256 | /* TODO: sigNaNs*/ |
256 | /* TODO: sigNaNs*/ |
257 | return 1; |
257 | return 1; |
258 | }; |
258 | }; |
259 | 259 | ||
260 | if (isFloat32eq(fa,fb)) { |
260 | if (isFloat32eq(fa, fb)) { |
261 | return 0; |
261 | return 0; |
262 | }; |
262 | }; |
263 | 263 | ||
264 | if (isFloat32lt(fa,fb)) { |
264 | if (isFloat32lt(fa, fb)) { |
265 | return -1; |
265 | return -1; |
266 | }; |
266 | }; |
267 | 267 | ||
268 | return 1; |
268 | return 1; |
269 | } |
269 | } |
270 | 270 | ||
271 | /** Return positive value, if a>b and neither is NaN*/ |
271 | /** Return positive value, if a>b and neither is NaN*/ |
272 | int __gtsf2(float a, float b) |
272 | int __gtsf2(float a, float b) |
273 | { |
273 | { |
274 | float32 fa,fb; |
274 | float32 fa, fb; |
275 | fa.f=a; |
275 | fa.f = a; |
276 | fb.f=b; |
276 | fb.f = b; |
277 | if ((isFloat32NaN(fa))||(isFloat32NaN(fb))) { |
277 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
278 | /* TODO: sigNaNs*/ |
278 | /* TODO: sigNaNs*/ |
279 | return -1; |
279 | return -1; |
280 | }; |
280 | }; |
281 | if (isFloat32gt(fa, fb)) { |
281 | if (isFloat32gt(fa, fb)) { |
282 | return 1; |
282 | return 1; |
Line 286... | Line 286... | ||
286 | 286 | ||
287 | /* Other functions */ |
287 | /* Other functions */ |
288 | 288 | ||
289 | float __powisf2(float a, int b) |
289 | float __powisf2(float a, int b) |
290 | { |
290 | { |
291 | //TODO: |
291 | /* TODO: */ |
292 | } |
292 | } |
293 | 293 | ||
294 | float __mulsc3(float a, float b, float c, float d) |
294 | float __mulsc3(float a, float b, float c, float d) |
295 | { |
295 | { |
296 | //TODO: |
296 | /* TODO: */ |
297 | } |
297 | } |
298 | 298 | ||
299 | float __divsc3(float a, float b, float c, float d) |
299 | float __divsc3(float a, float b, float c, float d) |
300 | { |
300 | { |
301 | //TODO: |
301 | /* TODO: */ |
302 | } |
302 | } |
303 | 303 |