2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, SPLog
,
15 AROS_LHA(float, fnum1
, D0
),
18 struct Library
*, MathTransBase
, 14, MathTrans
)
21 Calculate logarithm (base e) of the given ffp number
30 negative : result is negative
31 overflow : argument was negative
38 If the Argument is negative set overflow-flag and return 0.
39 If the Argument is 0 return 0xffffffff.
43 (ld is the logarithm with base 2)
44 (ln is the logarithm with base e)
48 ln fnum1 = ln ( M * 2^E ) =
55 = ----- + E * ----- = [ld 2 = 1]
62 ld e can be precalculated, of course.
63 For calculating ld M see file intern_spld.c
65 *****************************************************************************/
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 -> return (-infinity) */
79 if (fnum1
== 0) return FFP_Ninfty
;
81 /* convert the Exponent of the argument (fnum1) to the ffp-format */
82 Exponent
= (fnum1
& FFPExponent_Mask
) - 0x40;
93 /* find the number of the highest set bit in the exponent */
97 while ( (Mask
& Exponent
) == 0)
102 Exponent
<<= (25 + i
);
103 Exponent
|= (0x47 - i
+ Sign
);
106 ld_M
= intern_SPLd((fnum1
& FFPMantisse_Mask
) | 0x40);
109 ** ln(fnum1) = --------
113 return SPMul( SPAdd(ld_M
, Exponent
), InvLde
);