Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mathieeesingbas / ieeespfix.c
blob61a44856ca645751c79070c729b29d1a9168f156
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingbas_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LH1(LONG, IEEESPFix,
14 /* SYNOPSIS */
15 AROS_LHA(float, y, D0),
17 /* LOCATION */
18 struct LibHeader *, MathIeeeSingBasBase, 5, Mathieeesingbas)
20 /* FUNCTION
21 Convert ieeesp-number to integer
23 INPUTS
25 RESULT
26 absolute value of y
28 Flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : ieeesp out of integer-range
33 BUGS
35 INTERNALS
37 *****************************************************************************/
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