Workaround for includes conflict that stopped compilation with GCC 3.
[cake.git] / rom / mathieeesingbas / ieeespfix.c
blobb9dee3219b17b281e602da639683283aea5ea143
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingbas_intern.h"
8 /*
9 FUNCTION
10 Convert ieeesp-number to integer
12 RESULT
13 absolute value of y
15 Flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : ieeesp out of integer-range
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
29 INTERNALS
31 HISTORY
34 AROS_LH1(LONG, IEEESPFix,
35 AROS_LHA(float, y, D0),
36 struct LibHeader *, MathIeeeSingBasBase, 5, Mathieeesingbas
39 AROS_LIBFUNC_INIT
41 LONG Res;
42 LONG Shift;
44 if ((y & IEEESPExponent_Mask) > 0x60000000 )
46 if(y < 0) /* don`t hurt the SR! */
48 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
49 return 0x80000000;
51 else
53 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
54 return 0x7fffffff;
58 if (0 == y || 0x80000000 == y) /* y=+-0; */
60 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
61 return 0;
64 Shift = (y & IEEESPExponent_Mask) >> 23;
65 Shift -=0x7e;
67 if ((char) Shift >= 25)
69 Res = ((y & IEEESPMantisse_Mask) | 0x00800000) << (Shift-24);
71 else
73 Res = ((y & IEEESPMantisse_Mask) | 0x00800000) >> (24 - Shift);
76 /* Test for a negative sign */
77 if (y < 0)
79 Res = -Res;
80 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
83 return Res;
85 AROS_LIBFUNC_EXIT