Subversion Repositories HelenOS

Rev

Rev 1787 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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