Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mathieeesingbas / ieeespfloor.c
blob5ad41c58a29716e756df2da358cb064b0cf96805
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(float, IEEESPFloor,
14 /* SYNOPSIS */
15 AROS_LHA(float, y, D0),
17 /* LOCATION */
18 struct LibHeader *, MathIeeeSingBasBase, 15, Mathieeesingbas)
20 /* FUNCTION
21 Calculate the largest integer ieeesp-number
22 less than or equal to fnum
24 INPUTS
26 RESULT
27 IEEE single precision floating point
29 Flags:
30 zero : result is zero
31 negative : result is negative
32 overflow : 0 (???)
34 EXAMPLE
35 IEEESPFloor(10.5) = 10
36 IEEESPFloor(0.5) = 0
37 IEEESPFloor(-0.5) = -1
38 IEEESPFloor(-10.5)= -11
40 BUGS
42 SEE ALSO
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 LONG Mask = 0x80000000;
52 if (0x7f880000 == y) return y;
54 if ((y & IEEESPExponent_Mask) < 0x3f800000)
56 if (y < 0) /* negative sign? */
58 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
59 return 0xbf800000; /* -1 */
61 else
63 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
64 return 0;
68 /* |fnum| >= 1 */
69 Mask >>= ((y & IEEESPExponent_Mask) >> 23) - 0x77;
71 /* y is negative */
72 if (y < 0)
74 /* is there anything behind the decimal dot? */
75 if (0 != (y & (~Mask)) )
77 y = IEEESPAdd(y, 0xbf800000 ); /* fnum = fnum -1; */
78 Mask = 0x80000000;
79 Mask >>= ((y & IEEESPExponent_Mask) >> 23) - 0x77;
83 if(y < 0) SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
85 return y & Mask;
87 AROS_LIBFUNC_EXIT