Rev 876 | Rev 1035 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 876 | Rev 1031 | ||
---|---|---|---|
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> |
- | |
42 | #include<types.h> |
- | |
43 | #include<functions.h> |
41 | #include<functions.h> |
44 | 42 | ||
45 | /* Arithmetic functions */ |
43 | /* Arithmetic functions */ |
46 | 44 | ||
47 | float __addsf3(float a, float b) |
45 | float __addsf3(float a, float b) |
48 | { |
46 | { |
49 | float32 fa, fb; |
47 | float32 fa, fb; |
50 | fa.f = a; |
48 | fa.f = a; |
51 | fb.f = b; |
49 | fb.f = b; |
52 | if (fa.parts.sign != fb.parts.sign) { |
50 | if (fa.parts.sign != fb.parts.sign) { |
53 | if (fa.parts.sign) { |
51 | if (fa.parts.sign) { |
54 | fa.parts.sign = 0; |
52 | fa.parts.sign = 0; |
55 | return subFloat32(fb, fa).f; |
53 | return subFloat32(fb, fa).f; |
56 | }; |
54 | }; |
57 | fb.parts.sign = 0; |
55 | fb.parts.sign = 0; |
58 | return subFloat32(fa, fb).f; |
56 | return subFloat32(fa, fb).f; |
59 | } |
57 | } |
60 | return addFloat32(fa, fb).f; |
58 | return addFloat32(fa, fb).f; |
61 | } |
59 | } |
62 | 60 | ||
63 | double __adddf3(double a, double b) |
61 | double __adddf3(double a, double b) |
64 | { |
62 | { |
65 | float64 da, db; |
63 | float64 da, db; |
66 | da.d = a; |
64 | da.d = a; |
67 | db.d = b; |
65 | db.d = b; |
68 | if (da.parts.sign != db.parts.sign) { |
66 | if (da.parts.sign != db.parts.sign) { |
69 | if (da.parts.sign) { |
67 | if (da.parts.sign) { |
70 | da.parts.sign = 0; |
68 | da.parts.sign = 0; |
71 | return subFloat64(db, da).d; |
69 | return subFloat64(db, da).d; |
72 | }; |
70 | }; |
73 | db.parts.sign = 0; |
71 | db.parts.sign = 0; |
74 | return subFloat64(da, db).d; |
72 | return subFloat64(da, db).d; |
75 | } |
73 | } |
76 | return addFloat64(da, db).d; |
74 | return addFloat64(da, db).d; |
77 | } |
75 | } |
78 | 76 | ||
79 | float __subsf3(float a, float b) |
77 | float __subsf3(float a, float b) |
80 | { |
78 | { |
81 | float32 fa, fb; |
79 | float32 fa, fb; |
82 | fa.f = a; |
80 | fa.f = a; |
83 | fb.f = b; |
81 | fb.f = b; |
84 | if (fa.parts.sign != fb.parts.sign) { |
82 | if (fa.parts.sign != fb.parts.sign) { |
85 | fb.parts.sign = !fb.parts.sign; |
83 | fb.parts.sign = !fb.parts.sign; |
86 | return addFloat32(fa, fb).f; |
84 | return addFloat32(fa, fb).f; |
87 | } |
85 | } |
88 | return subFloat32(fa, fb).f; |
86 | return subFloat32(fa, fb).f; |
89 | } |
87 | } |
90 | 88 | ||
91 | double __subdf3(double a, double b) |
89 | double __subdf3(double a, double b) |
92 | { |
90 | { |
93 | float64 da, db; |
91 | float64 da, db; |
94 | da.d = a; |
92 | da.d = a; |
95 | db.d = b; |
93 | db.d = b; |
96 | if (da.parts.sign != db.parts.sign) { |
94 | if (da.parts.sign != db.parts.sign) { |
97 | db.parts.sign = !db.parts.sign; |
95 | db.parts.sign = !db.parts.sign; |
98 | return addFloat64(da, db).d; |
96 | return addFloat64(da, db).d; |
99 | } |
97 | } |
100 | return subFloat64(da, db).d; |
98 | return subFloat64(da, db).d; |
101 | } |
99 | } |
102 | 100 | ||
103 | float __mulsf3(float a, float b) |
101 | float __mulsf3(float a, float b) |
104 | { |
102 | { |
105 | float32 fa, fb; |
103 | float32 fa, fb; |
106 | fa.f = a; |
104 | fa.f = a; |
107 | fb.f = b; |
105 | fb.f = b; |
108 | return mulFloat32(fa, fb).f; |
106 | return mulFloat32(fa, fb).f; |
109 | } |
107 | } |
110 | 108 | ||
111 | double __muldf3(double a, double b) |
109 | double __muldf3(double a, double b) |
112 | { |
110 | { |
113 | float64 da, db; |
111 | float64 da, db; |
114 | da.d = a; |
112 | da.d = a; |
115 | db.d = b; |
113 | db.d = b; |
116 | return mulFloat64(da, db).d; |
114 | return mulFloat64(da, db).d; |
117 | } |
115 | } |
118 | 116 | ||
119 | float __divsf3(float a, float b) |
117 | float __divsf3(float a, float b) |
120 | { |
118 | { |
121 | float32 fa, fb; |
119 | float32 fa, fb; |
122 | fa.f = a; |
120 | fa.f = a; |
123 | fb.f = b; |
121 | fb.f = b; |
124 | return divFloat32(fa, fb).f; |
122 | return divFloat32(fa, fb).f; |
125 | } |
123 | } |
126 | 124 | ||
127 | double __divdf3(double a, double b) |
125 | double __divdf3(double a, double b) |
128 | { |
126 | { |
129 | float64 da, db; |
127 | float64 da, db; |
130 | da.d = a; |
128 | da.d = a; |
131 | db.d = b; |
129 | db.d = b; |
132 | return divFloat64(da, db).d; |
130 | return divFloat64(da, db).d; |
133 | } |
131 | } |
134 | 132 | ||
135 | float __negsf2(float a) |
133 | float __negsf2(float a) |
136 | { |
134 | { |
137 | float32 fa; |
135 | float32 fa; |
138 | fa.f = a; |
136 | fa.f = a; |
139 | fa.parts.sign = !fa.parts.sign; |
137 | fa.parts.sign = !fa.parts.sign; |
140 | return fa.f; |
138 | return fa.f; |
141 | } |
139 | } |
142 | 140 | ||
143 | double __negdf2(double a) |
141 | double __negdf2(double a) |
144 | { |
142 | { |
145 | float64 fa; |
143 | float64 fa; |
146 | fa.d = a; |
144 | fa.d = a; |
147 | fa.parts.sign = !fa.parts.sign; |
145 | fa.parts.sign = !fa.parts.sign; |
148 | return fa.d; |
146 | return fa.d; |
149 | } |
147 | } |
150 | 148 | ||
151 | /* Conversion functions */ |
149 | /* Conversion functions */ |
152 | 150 | ||
153 | double __extendsfdf2(float a) |
151 | double __extendsfdf2(float a) |
154 | { |
152 | { |
155 | float32 fa; |
153 | float32 fa; |
156 | fa.f = a; |
154 | fa.f = a; |
157 | return convertFloat32ToFloat64(fa).d; |
155 | return convertFloat32ToFloat64(fa).d; |
158 | } |
156 | } |
159 | 157 | ||
160 | float __truncdfsf2(double a) |
158 | float __truncdfsf2(double a) |
161 | { |
159 | { |
162 | float64 da; |
160 | float64 da; |
163 | da.d = a; |
161 | da.d = a; |
164 | return convertFloat64ToFloat32(da).f; |
162 | return convertFloat64ToFloat32(da).f; |
165 | } |
163 | } |
166 | 164 | ||
167 | int __fixsfsi(float a) |
165 | int __fixsfsi(float a) |
168 | { |
166 | { |
169 | float32 fa; |
167 | float32 fa; |
170 | fa.f = a; |
168 | fa.f = a; |
171 | 169 | ||
172 | return float32_to_int(fa); |
170 | return float32_to_int(fa); |
173 | } |
171 | } |
174 | int __fixdfsi(double a) |
172 | int __fixdfsi(double a) |
175 | { |
173 | { |
176 | float64 da; |
174 | float64 da; |
177 | da.d = a; |
175 | da.d = a; |
178 | 176 | ||
179 | return float64_to_int(da); |
177 | return float64_to_int(da); |
180 | } |
178 | } |
181 | 179 | ||
182 | long __fixsfdi(float a) |
180 | long __fixsfdi(float a) |
183 | { |
181 | { |
184 | float32 fa; |
182 | float32 fa; |
185 | fa.f = a; |
183 | fa.f = a; |
186 | 184 | ||
187 | return float32_to_long(fa); |
185 | return float32_to_long(fa); |
188 | } |
186 | } |
189 | long __fixdfdi(double a) |
187 | long __fixdfdi(double a) |
190 | { |
188 | { |
191 | float64 da; |
189 | float64 da; |
192 | da.d = a; |
190 | da.d = a; |
193 | 191 | ||
194 | return float64_to_long(da); |
192 | return float64_to_long(da); |
195 | } |
193 | } |
196 | 194 | ||
197 | long long __fixsfti(float a) |
195 | long long __fixsfti(float a) |
198 | { |
196 | { |
199 | float32 fa; |
197 | float32 fa; |
200 | fa.f = a; |
198 | fa.f = a; |
201 | 199 | ||
202 | return float32_to_longlong(fa); |
200 | return float32_to_longlong(fa); |
203 | } |
201 | } |
204 | long long __fixdfti(double a) |
202 | long long __fixdfti(double a) |
205 | { |
203 | { |
206 | float64 da; |
204 | float64 da; |
207 | da.d = a; |
205 | da.d = a; |
208 | 206 | ||
209 | return float64_to_longlong(da); |
207 | return float64_to_longlong(da); |
210 | } |
208 | } |
211 | 209 | ||
212 | unsigned int __fixunssfsi(float a) |
210 | unsigned int __fixunssfsi(float a) |
213 | { |
211 | { |
214 | float32 fa; |
212 | float32 fa; |
215 | fa.f = a; |
213 | fa.f = a; |
216 | 214 | ||
217 | return float32_to_uint(fa); |
215 | return float32_to_uint(fa); |
218 | } |
216 | } |
219 | unsigned int __fixunsdfsi(double a) |
217 | unsigned int __fixunsdfsi(double a) |
220 | { |
218 | { |
221 | float64 da; |
219 | float64 da; |
222 | da.d = a; |
220 | da.d = a; |
223 | 221 | ||
224 | return float64_to_uint(da); |
222 | return float64_to_uint(da); |
225 | } |
223 | } |
226 | 224 | ||
227 | unsigned long __fixunssfdi(float a) |
225 | unsigned long __fixunssfdi(float a) |
228 | { |
226 | { |
229 | float32 fa; |
227 | float32 fa; |
230 | fa.f = a; |
228 | fa.f = a; |
231 | 229 | ||
232 | return float32_to_ulong(fa); |
230 | return float32_to_ulong(fa); |
233 | } |
231 | } |
234 | unsigned long __fixunsdfdi(double a) |
232 | unsigned long __fixunsdfdi(double a) |
235 | { |
233 | { |
236 | float64 da; |
234 | float64 da; |
237 | da.d = a; |
235 | da.d = a; |
238 | 236 | ||
239 | return float64_to_ulong(da); |
237 | return float64_to_ulong(da); |
240 | } |
238 | } |
241 | 239 | ||
242 | unsigned long long __fixunssfti(float a) |
240 | unsigned long long __fixunssfti(float a) |
243 | { |
241 | { |
244 | float32 fa; |
242 | float32 fa; |
245 | fa.f = a; |
243 | fa.f = a; |
246 | 244 | ||
247 | return float32_to_ulonglong(fa); |
245 | return float32_to_ulonglong(fa); |
248 | } |
246 | } |
249 | unsigned long long __fixunsdfti(double a) |
247 | unsigned long long __fixunsdfti(double a) |
250 | { |
248 | { |
251 | float64 da; |
249 | float64 da; |
252 | da.d = a; |
250 | da.d = a; |
253 | 251 | ||
254 | return float64_to_ulonglong(da); |
252 | return float64_to_ulonglong(da); |
255 | } |
253 | } |
256 | 254 | ||
257 | float __floatsisf(int i) |
255 | float __floatsisf(int i) |
258 | { |
256 | { |
259 | float32 fa; |
257 | float32 fa; |
260 | 258 | ||
261 | fa = int_to_float32(i); |
259 | fa = int_to_float32(i); |
262 | return fa.f; |
260 | return fa.f; |
263 | } |
261 | } |
264 | double __floatsidf(int i) |
262 | double __floatsidf(int i) |
265 | { |
263 | { |
266 | float64 da; |
264 | float64 da; |
267 | 265 | ||
268 | da = int_to_float64(i); |
266 | da = int_to_float64(i); |
269 | return da.d; |
267 | return da.d; |
270 | } |
268 | } |
271 | 269 | ||
272 | float __floatdisf(long i) |
270 | float __floatdisf(long i) |
273 | { |
271 | { |
274 | float32 fa; |
272 | float32 fa; |
275 | 273 | ||
276 | fa = long_to_float32(i); |
274 | fa = long_to_float32(i); |
277 | return fa.f; |
275 | return fa.f; |
278 | } |
276 | } |
279 | double __floatdidf(long i) |
277 | double __floatdidf(long i) |
280 | { |
278 | { |
281 | float64 da; |
279 | float64 da; |
282 | 280 | ||
283 | da = long_to_float64(i); |
281 | da = long_to_float64(i); |
284 | return da.d; |
282 | return da.d; |
285 | } |
283 | } |
286 | 284 | ||
287 | float __floattisf(long long i) |
285 | float __floattisf(long long i) |
288 | { |
286 | { |
289 | float32 fa; |
287 | float32 fa; |
290 | 288 | ||
291 | fa = longlong_to_float32(i); |
289 | fa = longlong_to_float32(i); |
292 | return fa.f; |
290 | return fa.f; |
293 | } |
291 | } |
294 | double __floattidf(long long i) |
292 | double __floattidf(long long i) |
295 | { |
293 | { |
296 | float64 da; |
294 | float64 da; |
297 | 295 | ||
298 | da = longlong_to_float64(i); |
296 | da = longlong_to_float64(i); |
299 | return da.d; |
297 | return da.d; |
300 | } |
298 | } |
301 | 299 | ||
302 | float __floatunsisf(unsigned int i) |
300 | float __floatunsisf(unsigned int i) |
303 | { |
301 | { |
304 | float32 fa; |
302 | float32 fa; |
305 | 303 | ||
306 | fa = uint_to_float32(i); |
304 | fa = uint_to_float32(i); |
307 | return fa.f; |
305 | return fa.f; |
308 | } |
306 | } |
309 | double __floatunsidf(unsigned int i) |
307 | double __floatunsidf(unsigned int i) |
310 | { |
308 | { |
311 | float64 da; |
309 | float64 da; |
312 | 310 | ||
313 | da = uint_to_float64(i); |
311 | da = uint_to_float64(i); |
314 | return da.d; |
312 | return da.d; |
315 | } |
313 | } |
316 | 314 | ||
317 | float __floatundisf(unsigned long i) |
315 | float __floatundisf(unsigned long i) |
318 | { |
316 | { |
319 | float32 fa; |
317 | float32 fa; |
320 | 318 | ||
321 | fa = ulong_to_float32(i); |
319 | fa = ulong_to_float32(i); |
322 | return fa.f; |
320 | return fa.f; |
323 | } |
321 | } |
324 | double __floatundidf(unsigned long i) |
322 | double __floatundidf(unsigned long i) |
325 | { |
323 | { |
326 | float64 da; |
324 | float64 da; |
327 | 325 | ||
328 | da = ulong_to_float64(i); |
326 | da = ulong_to_float64(i); |
329 | return da.d; |
327 | return da.d; |
330 | } |
328 | } |
331 | 329 | ||
332 | float __floatuntisf(unsigned long long i) |
330 | float __floatuntisf(unsigned long long i) |
333 | { |
331 | { |
334 | float32 fa; |
332 | float32 fa; |
335 | 333 | ||
336 | fa = ulonglong_to_float32(i); |
334 | fa = ulonglong_to_float32(i); |
337 | return fa.f; |
335 | return fa.f; |
338 | } |
336 | } |
339 | double __floatuntidf(unsigned long long i) |
337 | double __floatuntidf(unsigned long long i) |
340 | { |
338 | { |
341 | float64 da; |
339 | float64 da; |
342 | 340 | ||
343 | da = ulonglong_to_float64(i); |
341 | da = ulonglong_to_float64(i); |
344 | return da.d; |
342 | return da.d; |
345 | } |
343 | } |
346 | 344 | ||
347 | /* Comparison functions */ |
345 | /* Comparison functions */ |
348 | /* Comparison functions */ |
346 | /* Comparison functions */ |
349 | 347 | ||
350 | /* a<b .. -1 |
348 | /* a<b .. -1 |
351 | * a=b .. 0 |
349 | * a=b .. 0 |
352 | * a>b .. 1 |
350 | * a>b .. 1 |
353 | * */ |
351 | * */ |
354 | 352 | ||
355 | int __cmpsf2(float a, float b) |
353 | int __cmpsf2(float a, float b) |
356 | { |
354 | { |
357 | float32 fa, fb; |
355 | float32 fa, fb; |
358 | fa.f = a; |
356 | fa.f = a; |
359 | fb.f = b; |
357 | fb.f = b; |
360 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
358 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
361 | return 1; /* no special constant for unordered - maybe signaled? */ |
359 | return 1; /* no special constant for unordered - maybe signaled? */ |
362 | }; |
360 | }; |
363 | 361 | ||
364 | 362 | ||
365 | if (isFloat32eq(fa, fb)) { |
363 | if (isFloat32eq(fa, fb)) { |
366 | return 0; |
364 | return 0; |
367 | }; |
365 | }; |
368 | 366 | ||
369 | if (isFloat32lt(fa, fb)) { |
367 | if (isFloat32lt(fa, fb)) { |
370 | return -1; |
368 | return -1; |
371 | }; |
369 | }; |
372 | return 1; |
370 | return 1; |
373 | } |
371 | } |
374 | 372 | ||
375 | int __unordsf2(float a, float b) |
373 | int __unordsf2(float a, float b) |
376 | { |
374 | { |
377 | float32 fa, fb; |
375 | float32 fa, fb; |
378 | fa.f = a; |
376 | fa.f = a; |
379 | fb.f = b; |
377 | fb.f = b; |
380 | return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ); |
378 | return ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ); |
381 | } |
379 | } |
382 | 380 | ||
383 | /** |
381 | /** |
384 | * @return zero, if neither argument is a NaN and are equal |
382 | * @return zero, if neither argument is a NaN and are equal |
385 | * */ |
383 | * */ |
386 | int __eqsf2(float a, float b) |
384 | int __eqsf2(float a, float b) |
387 | { |
385 | { |
388 | float32 fa, fb; |
386 | float32 fa, fb; |
389 | fa.f = a; |
387 | fa.f = a; |
390 | fb.f = b; |
388 | fb.f = b; |
391 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
389 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
392 | /* TODO: sigNaNs*/ |
390 | /* TODO: sigNaNs*/ |
393 | return 1; |
391 | return 1; |
394 | }; |
392 | }; |
395 | return isFloat32eq(fa, fb) - 1; |
393 | return isFloat32eq(fa, fb) - 1; |
396 | } |
394 | } |
397 | 395 | ||
398 | /* strange behavior, but it was in gcc documentation */ |
396 | /* strange behavior, but it was in gcc documentation */ |
399 | int __nesf2(float a, float b) |
397 | int __nesf2(float a, float b) |
400 | { |
398 | { |
401 | return __eqsf2(a, b); |
399 | return __eqsf2(a, b); |
402 | } |
400 | } |
403 | 401 | ||
404 | /* return value >= 0 if a>=b and neither is NaN */ |
402 | /* return value >= 0 if a>=b and neither is NaN */ |
405 | int __gesf2(float a, float b) |
403 | int __gesf2(float a, float b) |
406 | { |
404 | { |
407 | float32 fa, fb; |
405 | float32 fa, fb; |
408 | fa.f = a; |
406 | fa.f = a; |
409 | fb.f = b; |
407 | fb.f = b; |
410 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
408 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
411 | /* TODO: sigNaNs*/ |
409 | /* TODO: sigNaNs*/ |
412 | return -1; |
410 | return -1; |
413 | }; |
411 | }; |
414 | 412 | ||
415 | if (isFloat32eq(fa, fb)) { |
413 | if (isFloat32eq(fa, fb)) { |
416 | return 0; |
414 | return 0; |
417 | }; |
415 | }; |
418 | 416 | ||
419 | if (isFloat32gt(fa, fb)) { |
417 | if (isFloat32gt(fa, fb)) { |
420 | return 1; |
418 | return 1; |
421 | }; |
419 | }; |
422 | 420 | ||
423 | return -1; |
421 | return -1; |
424 | } |
422 | } |
425 | 423 | ||
426 | /** Return negative value, if a<b and neither is NaN*/ |
424 | /** Return negative value, if a<b and neither is NaN*/ |
427 | int __ltsf2(float a, float b) |
425 | int __ltsf2(float a, float b) |
428 | { |
426 | { |
429 | float32 fa, fb; |
427 | float32 fa, fb; |
430 | fa.f = a; |
428 | fa.f = a; |
431 | fb.f = b; |
429 | fb.f = b; |
432 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
430 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
433 | /* TODO: sigNaNs*/ |
431 | /* TODO: sigNaNs*/ |
434 | return 1; |
432 | return 1; |
435 | }; |
433 | }; |
436 | if (isFloat32lt(fa, fb)) { |
434 | if (isFloat32lt(fa, fb)) { |
437 | return -1; |
435 | return -1; |
438 | }; |
436 | }; |
439 | return 0; |
437 | return 0; |
440 | } |
438 | } |
441 | 439 | ||
442 | /* return value <= 0 if a<=b and neither is NaN */ |
440 | /* return value <= 0 if a<=b and neither is NaN */ |
443 | int __lesf2(float a, float b) |
441 | int __lesf2(float a, float b) |
444 | { |
442 | { |
445 | float32 fa, fb; |
443 | float32 fa, fb; |
446 | fa.f = a; |
444 | fa.f = a; |
447 | fb.f = b; |
445 | fb.f = b; |
448 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
446 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
449 | /* TODO: sigNaNs*/ |
447 | /* TODO: sigNaNs*/ |
450 | return 1; |
448 | return 1; |
451 | }; |
449 | }; |
452 | 450 | ||
453 | if (isFloat32eq(fa, fb)) { |
451 | if (isFloat32eq(fa, fb)) { |
454 | return 0; |
452 | return 0; |
455 | }; |
453 | }; |
456 | 454 | ||
457 | if (isFloat32lt(fa, fb)) { |
455 | if (isFloat32lt(fa, fb)) { |
458 | return -1; |
456 | return -1; |
459 | }; |
457 | }; |
460 | 458 | ||
461 | return 1; |
459 | return 1; |
462 | } |
460 | } |
463 | 461 | ||
464 | /** Return positive value, if a>b and neither is NaN*/ |
462 | /** Return positive value, if a>b and neither is NaN*/ |
465 | int __gtsf2(float a, float b) |
463 | int __gtsf2(float a, float b) |
466 | { |
464 | { |
467 | float32 fa, fb; |
465 | float32 fa, fb; |
468 | fa.f = a; |
466 | fa.f = a; |
469 | fb.f = b; |
467 | fb.f = b; |
470 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
468 | if ( (isFloat32NaN(fa)) || (isFloat32NaN(fb)) ) { |
471 | /* TODO: sigNaNs*/ |
469 | /* TODO: sigNaNs*/ |
472 | return -1; |
470 | return -1; |
473 | }; |
471 | }; |
474 | if (isFloat32gt(fa, fb)) { |
472 | if (isFloat32gt(fa, fb)) { |
475 | return 1; |
473 | return 1; |
476 | }; |
474 | }; |
477 | return 0; |
475 | return 0; |
478 | } |
476 | } |
479 | 477 | ||
480 | /* Other functions */ |
478 | /* Other functions */ |
481 | 479 | ||
482 | float __powisf2(float a, int b) |
480 | float __powisf2(float a, int b) |
483 | { |
481 | { |
484 | /* TODO: */ |
- | |
485 | } |
- | |
486 | - | ||
487 | float __mulsc3(float a, float b, float c, float d) |
- | |
488 | { |
- | |
489 | /* TODO: */ |
- | |
490 | } |
- | |
491 | - | ||
492 | float __divsc3(float a, float b, float c, float d) |
- | |
493 | { |
- | |
494 | /* TODO: */ |
482 | /* TODO: */ |
495 | } |
483 | } |
496 | 484 | ||
497 | 485 |