2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathffp_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, SPFloor
,
15 AROS_LHA(float, y
, D0
),
18 struct LibHeader
*, MathBase
, 15, Mathffp
)
21 Calculate the largest integer ffp-number
22 less than or equal to fnum
31 negative : result is negative
44 The integer part of a ffp number are the left "exponent"-bits
47 Test the exponent for <= 0. This has to be done separately!
48 If the sign is negative then return -1 otherwise return 0.
50 Generate a mask of exponent(y) (where y is the given ffp-number)
51 bits starting with bit 31.
52 If y < 0 then test whether it is already an integer. If not
53 then y = y - 1 and generate that mask again. Use the
56 *****************************************************************************/
60 LONG Mask
= 0x80000000;
62 if (((char)y
& FFPExponent_Mask
) <= 0x40)
66 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
67 return 0x800000C1; /* -1 */
71 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
77 Mask
>>= ( ((char) y
& FFPExponent_Mask
) - 0x41);
78 Mask
|= FFPSign_Mask
| FFPExponent_Mask
;
80 /* fnum is negative */
83 /* is there anything behind the dot? */
84 if (0 != (y
& (~Mask
)) )
87 y
= SPAdd(y
, 0x800000c1); /* y = y -1; */
88 Mask
>>= ((char) y
& FFPExponent_Mask
) - 0x41;
89 Mask
|= FFPSign_Mask
| FFPExponent_Mask
;
95 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);