added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / mathieeesingbas / ieeespfloor.c
blobc67bb3f2c7f8faf8fc010c1ec03ec5e6080d9057
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingbas_intern.h"
8 /*
9 FUNCTION
10 Calculate the largest integer ieeesp-number less than or equal to
11 fnum
13 RESULT
14 IEEE single precision floating point
16 Flags:
17 zero : result is zero
18 negative : result is negative
19 overflow : 0 (???)
21 NOTES
23 EXAMPLE
24 floor(10.5) = 10
25 floor(0.5) = 0
26 floor(-0.5) = -1
27 floor(-10.5)= -11
29 BUGS
31 SEE ALSO
32 @Math.Floor@
34 INTERNALS
36 HISTORY
39 AROS_LH1(float, IEEESPFloor,
40 AROS_LHA(float, y, D0),
41 struct LibHeader *, MathIeeeSingBasBase, 15, Mathieeesingbas
44 AROS_LIBFUNC_INIT
46 LONG Mask = 0x80000000;
48 if (0x7f880000 == y) return y;
50 if ((y & IEEESPExponent_Mask) < 0x3f800000)
52 if (y < 0) /* negative sign? */
54 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
55 return 0xbf800000; /* -1 */
57 else
59 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
60 return 0;
64 /* |fnum| >= 1 */
65 Mask >>= ((y & IEEESPExponent_Mask) >> 23) - 0x77;
67 /* y is negative */
68 if (y < 0)
70 /* is there anything behind the decimal dot? */
71 if (0 != (y & (~Mask)) )
73 y = IEEESPAdd(y, 0xbf800000 ); /* fnum = fnum -1; */
74 Mask = 0x80000000;
75 Mask >>= ((y & IEEESPExponent_Mask) >> 23) - 0x77;
79 if(y < 0) SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
81 return y & Mask;
83 AROS_LIBFUNC_EXIT