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