|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\euser\maths\um_log.cpp |
|
15 // Floating point base 10 logarithm |
|
16 // |
|
17 // |
|
18 |
|
19 #include "um_std.h" |
|
20 |
|
21 #if defined(__USE_VFP_MATH) && !defined(__CPU_HAS_VFP) |
|
22 #error __USE_VFP_MATH was defined but not __CPU_HAS_VFP - impossible combination, check variant.mmh |
|
23 #endif |
|
24 |
|
25 |
|
26 #ifndef __USE_VFP_MATH |
|
27 |
|
28 EXPORT_C TInt Math::Log(TReal &aTrg,const TReal &aSrc) |
|
29 /** |
|
30 Calculates the logarithm to base 10 of a number. |
|
31 |
|
32 @param aTrg A reference containing the result. |
|
33 @param aSrc The number whose logarithm is required. |
|
34 |
|
35 @return KErrNone if successful, otherwise another of |
|
36 the system-wide error codes. |
|
37 */ |
|
38 // |
|
39 // Base 10 log routine. See Software manual by W.J.Cody & W.Waite |
|
40 // |
|
41 { |
|
42 |
|
43 TInt ret=Math::Ln(aTrg,aSrc); |
|
44 if (ret!=KErrNone) |
|
45 return(ret); |
|
46 aTrg*=KRln10; |
|
47 return(ret); |
|
48 } |
|
49 |
|
50 #else // __USE_VFP_MATH |
|
51 |
|
52 // definitions come from RVCT math library |
|
53 extern "C" TReal log10(TReal); |
|
54 |
|
55 EXPORT_C TInt Math::Log(TReal& aTrg, const TReal& aSrc) |
|
56 { |
|
57 aTrg = log10(aSrc); |
|
58 if (Math::IsFinite(aTrg)) |
|
59 return KErrNone; |
|
60 if (Math::IsInfinite(aTrg)) |
|
61 return KErrOverflow; |
|
62 SetNaN(aTrg); |
|
63 return KErrArgument; |
|
64 } |
|
65 |
|
66 #endif |