2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
10 Calculate logarithm (base e) of the given IEEE double precision number
13 IEEE double precision number
17 negative : result is negative
18 overflow : argument was negative
31 If the Argument is negative set overflow-flag and return NAN.
32 If the Argument is 0 return 0xFFF0000000000000.
33 If the Argument is pos. Infinity return pos. Infinity.
37 (ld is the logarithm with base 2)
38 (ln is the logarithm with base e)
41 ln y = ln ( M * 2^E ) =
48 = ----- + E * ----- = [ld 2 = 1]
55 ld e can be precalculated, of course.
56 For calculating ld M see file intern_ieeespld.c
61 AROS_LHQUAD1(double, IEEEDPLog
,
62 AROS_LHAQUAD(double, y
, D0
, D1
),
63 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 14, MathIeeeDoubTrans
68 QUAD Res
, tmp
, Exponent64
, ld_M
;
70 /* check for negative sign */
71 if ( is_lessSC(y
, 0x0, 0x0) /* y<0 */)
73 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
74 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
78 if ( is_eqC(y
, 0x0, 0x0) )
83 (IEEEDPSign_Mask_Hi
+ IEEEDPExponent_Mask_Hi
),
84 (IEEEDPSign_Mask_Lo
+ IEEEDPExponent_Mask_Lo
)
88 /* check for argument == 0 or argument == +infinity */
91 is_eqC(y
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
)
92 || is_eqC(y
, IEEEDPExponent_Mask_Hi
, IEEEDPExponent_Mask_Lo
)
98 /* convert the Exponent of the argument (y) to the ieeedp-format */
99 Exponent
= ((Get_High32of64(y
) & IEEEDPExponent_Mask_Hi
) >> 20) - 0x3fe;
100 Exponent64
= IEEEDPFlt(Exponent
);
103 AND64QC(tmp
, IEEEDPMantisse_Mask_Hi
, IEEEDPMantisse_Mask_Lo
);
104 OR64QC(tmp
, 0x3fe00000, 0x0);
105 ld_M
= intern_IEEEDPLd
107 (struct MathIeeeDoubTransBase
*) MathIeeeDoubTransBase
,
115 Set_Value64C(tmp
, 0x3fe62e42, 0xfefa39ef ); /* ln 2*/
116 return IEEEDPMul( IEEEDPAdd(ld_M
, Exponent64
), tmp
);