Subversion Repositories HelenOS-historic

Rev

Rev 1657 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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