Rev 874 | Rev 1031 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 874 | Rev 876 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Josef Cejka |
2 | * Copyright (C) 2005 Josef Cejka |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include<softfloat.h> |
29 | #include<softfloat.h> |
30 | #include<sftypes.h> |
30 | #include<sftypes.h> |
31 | 31 | ||
32 | #include<add.h> |
32 | #include<add.h> |
33 | #include<sub.h> |
33 | #include<sub.h> |
34 | #include<mul.h> |
34 | #include<mul.h> |
35 | #include<div.h> |
35 | #include<div.h> |
36 | 36 | ||
37 | #include<conversion.h> |
37 | #include<conversion.h> |
38 | #include<comparison.h> |
38 | #include<comparison.h> |
39 | #include<other.h> |
39 | #include<other.h> |
40 | 40 | ||
41 | #include<arch.h> |
41 | #include<arch.h> |
42 | #include<types.h> |
42 | #include<types.h> |
43 | #include<functions.h> |
43 | #include<functions.h> |
44 | 44 | ||
45 | /* Arithmetic functions */ |
45 | /* Arithmetic functions */ |
46 | 46 | ||
47 | float __addsf3(float a, float b) |
47 | float __addsf3(float a, float b) |
48 | { |
48 | { |
49 | float32 fa, fb; |
49 | float32 fa, fb; |
50 | fa.f = a; |
50 | fa.f = a; |
51 | fb.f = b; |
51 | fb.f = b; |
52 | if (fa.parts.sign != fb.parts.sign) { |
52 | if (fa.parts.sign != fb.parts.sign) { |
53 | if (fa.parts.sign) { |
53 | if (fa.parts.sign) { |
54 | fa.parts.sign = 0; |
54 | fa.parts.sign = 0; |
55 | return subFloat32(fb, fa).f; |
55 | return subFloat32(fb, fa).f; |
56 | }; |
56 | }; |
57 | fb.parts.sign = 0; |
57 | fb.parts.sign = 0; |
58 | return subFloat32(fa, fb).f; |
58 | return subFloat32(fa, fb).f; |
59 | } |
59 | } |
60 | return addFloat32(fa, fb).f; |
60 | return addFloat32(fa, fb).f; |
61 | } |
61 | } |
62 | 62 | ||
63 | double __adddf3(double a, double b) |
63 | double __adddf3(double a, double b) |
64 | { |
64 | { |
65 | float64 da, db; |
65 | float64 da, db; |
66 | da.d = a; |
66 | da.d = a; |
67 | db.d = b; |
67 | db.d = b; |
68 | if (da.parts.sign != db.parts.sign) { |
68 | if (da.parts.sign != db.parts.sign) { |
69 | if (da.parts.sign) { |
69 | if (da.parts.sign) { |
70 | da.parts.sign = 0; |
70 | da.parts.sign = 0; |
71 | return subFloat64(db, da).d; |
71 | return subFloat64(db, da).d; |
72 | }; |
72 | }; |
73 | db.parts.sign = 0; |
73 | db.parts.sign = 0; |
74 | return subFloat64(da, db).d; |
74 | return subFloat64(da, db).d; |
75 | } |
75 | } |
76 | return addFloat64(da, db).d; |
76 | return addFloat64(da, db).d; |
77 | } |
77 | } |
78 | 78 | ||
79 | float __subsf3(float a, float b) |
79 | float __subsf3(float a, float b) |
80 | { |
80 | { |
81 | float32 fa, fb; |
81 | float32 fa, fb; |
82 | fa.f = a; |
82 | fa.f = a; |
83 | fb.f = b; |
83 | fb.f = b; |
84 | if (fa.parts.sign != fb.parts.sign) { |
84 | if (fa.parts.sign != fb.parts.sign) { |
85 | fb.parts.sign = !fb.parts.sign; |
85 | fb.parts.sign = !fb.parts.sign; |
86 | return addFloat32(fa, fb).f; |
86 | return addFloat32(fa, fb).f; |
87 | } |
87 | } |
88 | return subFloat32(fa, fb).f; |
88 | return subFloat32(fa, fb).f; |
89 | } |
89 | } |
90 | 90 | ||
91 | double __subdf3(double a, double b) |
91 | double __subdf3(double a, double b) |
92 | { |
92 | { |
93 | float64 da, db; |
93 | float64 da, db; |
94 | da.d = a; |
94 | da.d = a; |
95 | db.d = b; |
95 | db.d = b; |
96 | if (da.parts.sign != db.parts.sign) { |
96 | if (da.parts.sign != db.parts.sign) { |
97 | db.parts.sign = !db.parts.sign; |
97 | db.parts.sign = !db.parts.sign; |
98 | return addFloat64(da, db).d; |
98 | return addFloat64(da, db).d; |
99 | } |
99 | } |
100 | return subFloat64(da, db).d; |
100 | return subFloat64(da, db).d; |
101 | } |
101 | } |
102 | 102 | ||
103 | float __mulsf3(float a, float b) |
103 | float __mulsf3(float a, float b) |
104 | { |
104 | { |
105 | float32 fa, fb; |
105 | float32 fa, fb; |
106 | fa.f = a; |
106 | fa.f = a; |
107 | fb.f = b; |
107 | fb.f = b; |
108 | return mulFloat32(fa, fb).f; |
108 | return mulFloat32(fa, fb).f; |
109 | } |
109 | } |
110 | 110 | ||
111 | double __muldf3(double a, double b) |
111 | double __muldf3(double a, double b) |
112 | { |
112 | { |
113 | float64 da, db; |
113 | float64 da, db; |
114 | da.d = a; |
114 | da.d = a; |
115 | db.d = b; |
115 | db.d = b; |
116 | return mulFloat64(da, db).d; |
116 | return mulFloat64(da, db).d; |
117 | } |
117 | } |
118 | 118 | ||
119 | float __divsf3(float a, float b) |
119 | float __divsf3(float a, float b) |
120 | { |
120 | { |
121 | float32 fa, fb; |
121 | float32 fa, fb; |
122 | fa.f = a; |
122 | fa.f = a; |
123 | fb.f = b; |
123 | fb.f = b; |
124 | return divFloat32(fa, fb).f; |
124 | return divFloat32(fa, fb).f; |
125 | } |
125 | } |
126 | 126 | ||
127 | double __divdf3(double a, double b) |
127 | double __divdf3(double a, double b) |
128 | { |
128 | { |
129 | float64 da, db; |
129 | float64 da, db; |
130 | da.d = a; |
130 | da.d = a; |
131 | db.d = b; |
131 | db.d = b; |
132 | return divFloat64(da, db).d; |
132 | return divFloat64(da, db).d; |
133 | } |
133 | } |
134 | 134 | ||
135 | float __negsf2(float a) |
135 | float __negsf2(float a) |
136 | { |
136 | { |
137 | float32 fa; |
137 | float32 fa; |
138 | fa.f = a; |
138 | fa.f = a; |
139 | fa.parts.sign = !fa.parts.sign; |
139 | fa.parts.sign = !fa.parts.sign; |
140 | return fa.f; |
140 | return fa.f; |
141 | } |
141 | } |
142 | 142 | ||
143 | double __negdf2(double a) |
143 | double __negdf2(double a) |
144 | { |
144 | { |
145 | float64 fa; |
145 | float64 fa; |
146 | fa.d = a; |
146 | fa.d = a; |
147 | fa.parts.sign = !fa.parts.sign; |
147 | fa.parts.sign = !fa.parts.sign; |
148 | return fa.d; |
148 | return fa.d; |
149 | } |
149 | } |
150 | 150 | ||
151 | /* Conversion functions */ |
151 | /* Conversion functions */ |
152 | 152 | ||
153 | double __extendsfdf2(float a) |
153 | double __extendsfdf2(float a) |
154 | { |
154 | { |
155 | float32 fa; |
155 | float32 fa; |
156 | fa.f = a; |
156 | fa.f = a; |
157 | return convertFloat32ToFloat64(fa).d; |
157 | return convertFloat32ToFloat64(fa).d; |
158 | } |
158 | } |
159 | 159 | ||
160 | float __truncdfsf2(double a) |
160 | float __truncdfsf2(double a) |
161 | { |
161 | { |
162 | float64 da; |
162 | float64 da; |
163 | da.d = a; |
163 | da.d = a; |
164 | return convertFloat64ToFloat32(da).f; |
164 | return convertFloat64ToFloat32(da).f; |
165 | } |
165 | } |
166 | 166 | ||
167 | int __fixsfsi(float a) |
167 | int __fixsfsi(float a) |
168 | { |
168 | { |
169 | float32 fa; |
169 | float32 fa; |
170 | fa.f = a; |
170 | fa.f = a; |
171 | 171 | ||
172 | return float32_to_int(fa); |
172 | return float32_to_int(fa); |
173 | } |
173 | } |
174 | int __fixdfsi(double a) |
174 | int __fixdfsi(double a) |
175 | { |
175 | { |
176 | float64 da; |
176 | float64 da; |
177 | da.d = a; |
177 | da.d = a; |
178 | 178 | ||
179 | return float64_to_int(da); |
179 | return float64_to_int(da); |
180 | } |
180 | } |
181 | 181 | ||
182 | long __fixsfdi(float a) |
182 | long __fixsfdi(float a) |
183 | { |
183 | { |
184 | float32 fa; |
184 | float32 fa; |
185 | fa.f = a; |
185 | fa.f = a; |
186 | 186 | ||
187 | return float32_to_long(fa); |
187 | return float32_to_long(fa); |
188 | } |
188 | } |
189 | long __fixdfdi(double a) |
189 | long __fixdfdi(double a) |
190 | { |
190 | { |
191 | float64 da; |
191 | float64 da; |
192 | da.d = a; |
192 | da.d = a; |
193 | 193 | ||
194 | return float64_to_long(da); |
194 | return float64_to_long(da); |
195 | } |
195 | } |
196 | 196 | ||
197 | long long __fixsfti(float a) |
197 | long long __fixsfti(float a) |
198 | { |
198 | { |
199 | float32 fa; |
199 | float32 fa; |
200 | fa.f = a; |
200 | fa.f = a; |
201 | 201 | ||
202 | return float32_to_longlong(fa); |
202 | return float32_to_longlong(fa); |
203 | } |
203 | } |
204 | long long __fixdfti(double a) |
204 | long long __fixdfti(double a) |
205 | { |
205 | { |
206 | float64 da; |
206 | float64 da; |
207 | da.d = a; |
207 | da.d = a; |
208 | 208 | ||
209 | return float64_to_longlong(da); |
209 | return float64_to_longlong(da); |
210 | } |
210 | } |
211 | 211 | ||
212 | unsigned int __fixunssfsi(float a) |
212 | unsigned int __fixunssfsi(float a) |
213 | { |
213 | { |
214 | float32 fa; |
214 | float32 fa; |
215 | fa.f = a; |
215 | fa.f = a; |
216 | 216 | ||
217 | return float32_to_uint(fa); |
217 | return float32_to_uint(fa); |
218 | } |
218 | } |
219 | unsigned int __fixunsdfsi(double a) |
219 | unsigned int __fixunsdfsi(double a) |
220 | { |
220 | { |
221 | float64 da; |
221 | float64 da; |
222 | da.d = a; |
222 | da.d = a; |
223 | 223 | ||
224 | return float64_to_uint(da); |
224 | return float64_to_uint(da); |
225 | } |
225 | } |
226 | 226 | ||
227 | unsigned long __fixunssfdi(float a) |
227 | unsigned long __fixunssfdi(float a) |
228 | { |
228 | { |
229 | float32 fa; |
229 | float32 fa; |
230 | fa.f = a; |
230 | fa.f = a; |
231 | 231 | ||
232 | return float32_to_ulong(fa); |
232 | return float32_to_ulong(fa); |
233 | } |
233 | } |
234 | unsigned long __fixunsdfdi(double a) |
234 | unsigned long __fixunsdfdi(double a) |
235 | { |
235 | { |
236 | float64 da; |
236 | float64 da; |
237 | da.d = a; |
237 | da.d = a; |
238 | 238 | ||
239 | return float64_to_ulong(da); |
239 | return float64_to_ulong(da); |
240 | } |
240 | } |
241 | 241 | ||
242 | unsigned long long __fixunssfti(float a) |
242 | unsigned long long __fixunssfti(float a) |
243 | { |
243 | { |
244 | float32 fa; |
244 | float32 fa; |
245 | fa.f = a; |
245 | fa.f = a; |
246 | 246 | ||
247 | return float32_to_ulonglong(fa); |
247 | return float32_to_ulonglong(fa); |
248 | } |
248 | } |
249 | unsigned long long __fixunsdfti(double a) |
249 | unsigned long long __fixunsdfti(double a) |
250 | { |
250 | { |
251 | float64 da; |
251 | float64 da; |
252 | da.d = a; |
252 | da.d = a; |
253 | 253 | ||
254 | return float64_to_ulonglong(da); |
254 | return float64_to_ulonglong(da); |
255 | } |
255 | } |
256 | 256 | ||
257 | float __floatsisf(int i) |
257 | float __floatsisf(int i) |
258 | { |
258 | { |
259 | float32 fa; |
259 | float32 fa; |
260 | 260 | ||
261 | fa = int_to_float32(i); |
261 | fa = int_to_float32(i); |
262 | return fa.f; |
262 | return fa.f; |
263 | } |
263 | } |
264 | double __floatsidf(int i) |
264 | double __floatsidf(int i) |
265 | { |
265 | { |
- | 266 | float64 da; |
|
- | 267 | ||
- | 268 | da = int_to_float64(i); |
|
- | 269 | return da.d; |
|
266 | } |
270 | } |
267 | 271 | ||
268 | float __floatdisf(long i) |
272 | float __floatdisf(long i) |
269 | { |
273 | { |
270 | float32 fa; |
274 | float32 fa; |
271 | 275 | ||
272 | fa = long_to_float32(i); |
276 | fa = long_to_float32(i); |
273 | return fa.f; |
277 | return fa.f; |
274 | } |
278 | } |
275 | double __floatdidf(long i) |
279 | double __floatdidf(long i) |
276 | { |
280 | { |
- | 281 | float64 da; |
|
- | 282 | ||
- | 283 | da = long_to_float64(i); |
|
- | 284 | return da.d; |
|
277 | } |
285 | } |
278 | 286 | ||
279 | float __floattisf(long long i) |
287 | float __floattisf(long long i) |
280 | { |
288 | { |
281 | float32 fa; |
289 | float32 fa; |
282 | 290 | ||
283 | fa = longlong_to_float32(i); |
291 | fa = longlong_to_float32(i); |
284 | return fa.f; |
292 | return fa.f; |
285 | } |
293 | } |
286 | double __floattidf(long long i) |
294 | double __floattidf(long long i) |
287 | { |
295 | { |
- | 296 | float64 da; |
|
- | 297 | ||
- | 298 | da = longlong_to_float64(i); |
|
- | 299 | return da.d; |
|
288 | } |
300 | } |
289 | 301 | ||
290 | float __floatunsisf(unsigned int i) |
302 | float __floatunsisf(unsigned int i) |
291 | { |
303 | { |
292 | float32 fa; |
304 | float32 fa; |
293 | 305 | ||
294 | fa = uint_to_float32(i); |
306 | fa = uint_to_float32(i); |
295 | return fa.f; |
307 | return fa.f; |
296 | } |
308 | } |
297 | double __floatunsidf(unsigned int i) |
309 | double __floatunsidf(unsigned int i) |
298 | { |
310 | { |
- | 311 | float64 da; |
|
- | 312 | ||
- | 313 | da = uint_to_float64(i); |
|
- | 314 | return da.d; |
|
299 | } |
315 | } |
300 | 316 | ||
301 | float __floatundisf(unsigned long i) |
317 | float __floatundisf(unsigned long i) |
302 | { |
318 | { |
303 | float32 fa; |
319 | float32 fa; |
304 | 320 | ||
305 | fa = ulong_to_float32(i); |
321 | fa = ulong_to_float32(i); |
306 | return fa.f; |
322 | return fa.f; |
307 | } |
323 | } |
308 | double __floatundidf(unsigned long i) |
324 | double __floatundidf(unsigned long i) |
309 | { |
325 | { |
- | 326 | float64 da; |
|
- | 327 | ||
- | 328 | da = ulong_to_float64(i); |
|
- | 329 | return da.d; |
|
310 | } |
330 | } |
311 | 331 | ||
312 | float __floatuntisf(unsigned long long i) |
332 | float __floatuntisf(unsigned long long i) |
313 | { |
333 | { |
314 | float32 fa; |
334 | float32 fa; |
315 | 335 | ||
316 | fa = ulonglong_to_float32(i); |
336 | fa = ulonglong_to_float32(i); |
317 | return fa.f; |
337 | return fa.f; |
318 | } |
338 | } |
319 | double __floatuntidf(unsigned long long i) |
339 | double __floatuntidf(unsigned long long i) |
320 | { |
340 | { |
- | 341 | float64 da; |
|
- | 342 | ||
- | 343 | da = ulonglong_to_float64(i); |
|
- | 344 | return da.d; |
|
321 | } |
345 | } |
322 | 346 | ||
323 | /* Comparison functions */ |
347 | /* Comparison functions */ |
324 | /* Comparison functions */ |
348 | /* Comparison functions */ |
325 | 349 | ||
326 | /* a<b .. -1 |
350 | /* a<b .. -1 |
327 | * a=b .. 0 |
351 | * a=b .. 0 |
328 | * a>b .. 1 |
352 | * a>b .. 1 |
329 | * */ |
353 | * */ |
330 | 354 | ||
331 | int __cmpsf2(float a, float b) |
355 | int __cmpsf2(float a, float b) |
332 | { |
356 | { |
333 | float32 fa, fb; |
357 | float32 fa, fb; |
334 | fa.f = a; |
358 | fa.f = a; |
335 | fb.f = b; |
359 | fb.f = b; |
336 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
360 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
337 | return 1; /* no special constant for unordered - maybe signaled? */ |
361 | return 1; /* no special constant for unordered - maybe signaled? */ |
338 | }; |
362 | }; |
339 | 363 | ||
340 | 364 | ||
341 | if (isFloat32eq(fa, fb)) { |
365 | if (isFloat32eq(fa, fb)) { |
342 | return 0; |
366 | return 0; |
343 | }; |
367 | }; |
344 | 368 | ||
345 | if (isFloat32lt(fa, fb)) { |
369 | if (isFloat32lt(fa, fb)) { |
346 | return -1; |
370 | return -1; |
347 | }; |
371 | }; |
348 | return 1; |
372 | return 1; |
349 | } |
373 | } |
350 | 374 | ||
351 | int __unordsf2(float a, float b) |
375 | int __unordsf2(float a, float b) |
352 | { |
376 | { |
353 | float32 fa, fb; |
377 | float32 fa, fb; |
354 | fa.f = a; |
378 | fa.f = a; |
355 | fb.f = b; |
379 | fb.f = b; |
356 | return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ); |
380 | return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ); |
357 | } |
381 | } |
358 | 382 | ||
359 | /** |
383 | /** |
360 | * @return zero, if neither argument is a NaN and are equal |
384 | * @return zero, if neither argument is a NaN and are equal |
361 | * */ |
385 | * */ |
362 | int __eqsf2(float a, float b) |
386 | int __eqsf2(float a, float b) |
363 | { |
387 | { |
364 | float32 fa, fb; |
388 | float32 fa, fb; |
365 | fa.f = a; |
389 | fa.f = a; |
366 | fb.f = b; |
390 | fb.f = b; |
367 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
391 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
368 | /* TODO: sigNaNs*/ |
392 | /* TODO: sigNaNs*/ |
369 | return 1; |
393 | return 1; |
370 | }; |
394 | }; |
371 | return isFloat32eq(fa, fb) - 1; |
395 | return isFloat32eq(fa, fb) - 1; |
372 | } |
396 | } |
373 | 397 | ||
374 | /* strange behavior, but it was in gcc documentation */ |
398 | /* strange behavior, but it was in gcc documentation */ |
375 | int __nesf2(float a, float b) |
399 | int __nesf2(float a, float b) |
376 | { |
400 | { |
377 | return __eqsf2(a, b); |
401 | return __eqsf2(a, b); |
378 | } |
402 | } |
379 | 403 | ||
380 | /* return value >= 0 if a>=b and neither is NaN */ |
404 | /* return value >= 0 if a>=b and neither is NaN */ |
381 | int __gesf2(float a, float b) |
405 | int __gesf2(float a, float b) |
382 | { |
406 | { |
383 | float32 fa, fb; |
407 | float32 fa, fb; |
384 | fa.f = a; |
408 | fa.f = a; |
385 | fb.f = b; |
409 | fb.f = b; |
386 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
410 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
387 | /* TODO: sigNaNs*/ |
411 | /* TODO: sigNaNs*/ |
388 | return -1; |
412 | return -1; |
389 | }; |
413 | }; |
390 | 414 | ||
391 | if (isFloat32eq(fa, fb)) { |
415 | if (isFloat32eq(fa, fb)) { |
392 | return 0; |
416 | return 0; |
393 | }; |
417 | }; |
394 | 418 | ||
395 | if (isFloat32gt(fa, fb)) { |
419 | if (isFloat32gt(fa, fb)) { |
396 | return 1; |
420 | return 1; |
397 | }; |
421 | }; |
398 | 422 | ||
399 | return -1; |
423 | return -1; |
400 | } |
424 | } |
401 | 425 | ||
402 | /** Return negative value, if a<b and neither is NaN*/ |
426 | /** Return negative value, if a<b and neither is NaN*/ |
403 | int __ltsf2(float a, float b) |
427 | int __ltsf2(float a, float b) |
404 | { |
428 | { |
405 | float32 fa, fb; |
429 | float32 fa, fb; |
406 | fa.f = a; |
430 | fa.f = a; |
407 | fb.f = b; |
431 | fb.f = b; |
408 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
432 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
409 | /* TODO: sigNaNs*/ |
433 | /* TODO: sigNaNs*/ |
410 | return 1; |
434 | return 1; |
411 | }; |
435 | }; |
412 | if (isFloat32lt(fa, fb)) { |
436 | if (isFloat32lt(fa, fb)) { |
413 | return -1; |
437 | return -1; |
414 | }; |
438 | }; |
415 | return 0; |
439 | return 0; |
416 | } |
440 | } |
417 | 441 | ||
418 | /* return value <= 0 if a<=b and neither is NaN */ |
442 | /* return value <= 0 if a<=b and neither is NaN */ |
419 | int __lesf2(float a, float b) |
443 | int __lesf2(float a, float b) |
420 | { |
444 | { |
421 | float32 fa, fb; |
445 | float32 fa, fb; |
422 | fa.f = a; |
446 | fa.f = a; |
423 | fb.f = b; |
447 | fb.f = b; |
424 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
448 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
425 | /* TODO: sigNaNs*/ |
449 | /* TODO: sigNaNs*/ |
426 | return 1; |
450 | return 1; |
427 | }; |
451 | }; |
428 | 452 | ||
429 | if (isFloat32eq(fa, fb)) { |
453 | if (isFloat32eq(fa, fb)) { |
430 | return 0; |
454 | return 0; |
431 | }; |
455 | }; |
432 | 456 | ||
433 | if (isFloat32lt(fa, fb)) { |
457 | if (isFloat32lt(fa, fb)) { |
434 | return -1; |
458 | return -1; |
435 | }; |
459 | }; |
436 | 460 | ||
437 | return 1; |
461 | return 1; |
438 | } |
462 | } |
439 | 463 | ||
440 | /** Return positive value, if a>b and neither is NaN*/ |
464 | /** Return positive value, if a>b and neither is NaN*/ |
441 | int __gtsf2(float a, float b) |
465 | int __gtsf2(float a, float b) |
442 | { |
466 | { |
443 | float32 fa, fb; |
467 | float32 fa, fb; |
444 | fa.f = a; |
468 | fa.f = a; |
445 | fb.f = b; |
469 | fb.f = b; |
446 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
470 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
447 | /* TODO: sigNaNs*/ |
471 | /* TODO: sigNaNs*/ |
448 | return -1; |
472 | return -1; |
449 | }; |
473 | }; |
450 | if (isFloat32gt(fa, fb)) { |
474 | if (isFloat32gt(fa, fb)) { |
451 | return 1; |
475 | return 1; |
452 | }; |
476 | }; |
453 | return 0; |
477 | return 0; |
454 | } |
478 | } |
455 | 479 | ||
456 | /* Other functions */ |
480 | /* Other functions */ |
457 | 481 | ||
458 | float __powisf2(float a, int b) |
482 | float __powisf2(float a, int b) |
459 | { |
483 | { |
460 | /* TODO: */ |
484 | /* TODO: */ |
461 | } |
485 | } |
462 | 486 | ||
463 | float __mulsc3(float a, float b, float c, float d) |
487 | float __mulsc3(float a, float b, float c, float d) |
464 | { |
488 | { |
465 | /* TODO: */ |
489 | /* TODO: */ |
466 | } |
490 | } |
467 | 491 | ||
468 | float __divsc3(float a, float b, float c, float d) |
492 | float __divsc3(float a, float b, float c, float d) |
469 | { |
493 | { |
470 | /* TODO: */ |
494 | /* TODO: */ |
471 | } |
495 | } |
472 | 496 | ||
473 | 497 |