2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
6 #include "mathffp_intern.h"
16 negative : result is negative
17 overflow : ffp is not exactly the integer
28 Return zero for x == 0.<br/>
29 If <code>x < 0</code> set the sign-bit and calculate the absolute value
31 Find out which bit is the highest-set bit. If the number
32 of that bit <code>> 24</code> then the result has the highest bit
33 of the mantisse set to one and the exponent equals the
34 number of the bit + 2. This is due to the fact that we only
35 have 24 bits for the mantisse.
36 Otherwise rotate the given integer by
37 <code>(32 - (number of highes set bit + 1))</code> bits to the left and
38 calculate the result from that.
44 AROS_LH1(float, SPFlt
,
45 AROS_LHA(LONG
, inum
, D0
),
46 struct LibHeader
*, MathBase
, 6, Mathffp
52 LONG TestMask
= 0xFFFFFFFF;
55 kprintf("SPFlt(%d)=",inum
);
59 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
69 /* find out which is the number of the highes set bit */
70 while (TestMask
& inum
)
76 /* Exponent = number of highest set bit + 1 */
78 inum
<<= (32 - Exponent
);
79 if ((char) inum
< 0) inum
+=0x100;
80 inum
&= FFPMantisse_Mask
;
82 /* adapt the exponent to the ffp format */
84 Res
|= inum
| Exponent
;
87 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
90 if (Exponent
> (25 + 0x40))
93 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);