2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathffp_intern.h"
10 Calculate the largest integer ffp-number less than or equal to
18 negative : result is negative
36 <p>The integer part of a ffp number are the left "exponent"-bits
39 Test the exponent for <code><= 0</code>. This has to be done separately!
40 If the sign is negative then return -1 otherwise return 0.</p>
42 <p>Generate a mask of exponent(y) (where y is the given ffp-number)
43 bits starting with bit 31.
44 If <code>y < 0</code> then test whether it is already an integer. If not
45 then y = y - 1 and generate that mask again. Use the
46 mask on the mantisse.</p>
51 AROS_LH1(float, SPFloor
,
52 AROS_LHA(float, y
, D0
),
53 struct LibHeader
*, MathBase
, 15, Mathffp
58 LONG Mask
= 0x80000000;
60 if (((char)y
& FFPExponent_Mask
) <= 0x40)
64 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
65 return 0x800000C1; /* -1 */
69 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
75 Mask
>>= ( ((char) y
& FFPExponent_Mask
) - 0x41);
76 Mask
|= FFPSign_Mask
| FFPExponent_Mask
;
78 /* fnum is negative */
81 /* is there anything behind the dot? */
82 if (0 != (y
& (~Mask
)) )
85 y
= SPAdd(y
, 0x800000c1); /* y = y -1; */
86 Mask
>>= ((char) y
& FFPExponent_Mask
) - 0x41;
87 Mask
|= FFPSign_Mask
| FFPExponent_Mask
;
93 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);