Subversion Repositories HelenOS

Rev

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

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