Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / mathtrans / spfieee.c
blob107db501d6f304be759df55c9ef0dee14c4212a9
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathtrans_intern.h"
8 /*
9 FUNCTION
10 Convert single precision ieee number to FFP number
12 RESULT
13 Motorola fast floating point number
15 flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : exponent of the ieee-number was out of range for
19 ffp
21 NOTES
23 EXAMPLE
25 BUGS
27 SEE ALSO
29 INTERNALS
31 HISTORY
34 AROS_LH1(float, SPFieee,
35 AROS_LHA(float, ieeenum, D0),
36 struct Library *, MathTransBase, 18, MathTrans
39 AROS_LIBFUNC_INIT
41 LONG Res;
43 /* check for ieeenum == 0 */
44 if (0 == ieeenum)
46 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
47 return 0;
50 /* calculate the exponent */
51 Res = (ieeenum & IEEESPExponent_Mask) >> 23;
52 Res = Res - 126 + 0x40;
54 /* exponent too big / small */
55 if ((char) Res < 0)
57 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
58 return Res;
61 Res |= (ieeenum << 8) | 0x80000000;
63 /* check ieeenum-number for a sign */
64 if (ieeenum < 0)
66 Res |= FFPSign_Mask;
67 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
70 return Res;
72 AROS_LIBFUNC_EXIT