2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
6 #include "mathieeesingtrans_intern.h"
10 Calculate logarithm (base 10) of the given IEEE single precision number
13 IEEE single precision number
17 negative : result is negative
18 overflow : argument was negative
31 If the Argument is negative set overflow-flag and return 0.
32 If the Argument is 0 return 0xffffffff.
36 (ld is the logarithm with base 2)
37 (log is the logarithm with base 10)
41 log y = log ( M * 2^E ) =
45 = log M + E * log (2) =
48 = ----- + E * ----- = [ld 2 = 1]
56 ld 10 can be precalculated, of course.
57 For calculating ld M see file intern_ieeespld.c
62 AROS_LH1(float, IEEESPLog10
,
63 AROS_LHA(float, y
, D0
),
64 struct Library
*, MathIeeeSingTransBase
, 21, MathIeeeSingTrans
69 LONG ld_M
, Exponent
, Mask
= 0x40, i
, Sign
;
71 /* check for negative sign */
74 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
78 /* check for argument == 0 or argument == +infinity */
79 if (0 == y
|| IEEESP_Pinfty
== y
) return y
;
81 /* convert the Exponent of the argument (y) to the ieeesp-format */
82 Exponent
= ((y
& IEEESPExponent_Mask
) >> 23) - 0x7e ;
87 Sign
= IEEESPSign_Mask
;
93 /* find the number of the highest set bit in the exponent */
97 while ( (Mask
& Exponent
) == 0)
103 Exponent
<<= (17 + i
);
104 Exponent
&= IEEESPMantisse_Mask
;
105 Exponent
|= ((0x85 - i
) << 23);
109 ld_M
= intern_IEEESPLd((y
& IEEESPMantisse_Mask
) | 0x3f000000);
113 log(fnum1) = --------
117 return IEEESPMul( IEEESPAdd(ld_M
, Exponent
), InvLd10
);