2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
8 /*****************************************************************************
12 AROS_LHQUAD1(double, IEEEDPLog
,
15 AROS_LHAQUAD(double, y
, D0
, D1
),
18 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 14, MathIeeeDoubTrans
)
21 Calculate logarithm (base e) of the given IEEE double precision number
26 IEEE double precision number
30 negative : result is negative
31 overflow : argument was negative
38 If the Argument is negative set overflow-flag and return NAN.
39 If the Argument is 0 return 0xFFF0000000000000.
40 If the Argument is pos. Infinity return pos. Infinity.
44 (ld is the logarithm with base 2)
45 (ln is the logarithm with base e)
48 ln y = 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_ieeespld.c
65 *****************************************************************************/
69 QUAD Res
, tmp
, Exponent64
, ld_M
;
71 /* check for negative sign */
72 if ( is_lessSC(y
, 0x0, 0x0) /* y<0 */)
74 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
75 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
79 if ( is_eqC(y
, 0x0, 0x0) )
84 (IEEEDPSign_Mask_Hi
+ IEEEDPExponent_Mask_Hi
),
85 (IEEEDPSign_Mask_Lo
+ IEEEDPExponent_Mask_Lo
)
89 /* check for argument == 0 or argument == +infinity */
92 is_eqC(y
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
)
93 || is_eqC(y
, IEEEDPExponent_Mask_Hi
, IEEEDPExponent_Mask_Lo
)
99 /* convert the Exponent of the argument (y) to the ieeedp-format */
100 Exponent
= ((Get_High32of64(y
) & IEEEDPExponent_Mask_Hi
) >> 20) - 0x3fe;
101 Exponent64
= IEEEDPFlt(Exponent
);
104 AND64QC(tmp
, IEEEDPMantisse_Mask_Hi
, IEEEDPMantisse_Mask_Lo
);
105 OR64QC(tmp
, 0x3fe00000, 0x0);
106 ld_M
= intern_IEEEDPLd
108 (struct MathIeeeDoubTransBase
*) MathIeeeDoubTransBase
,
116 Set_Value64C(tmp
, 0x3fe62e42, 0xfefa39ef ); /* ln 2*/
117 return IEEEDPMul( IEEEDPAdd(ld_M
, Exponent64
), tmp
);