summaryrefslogtreecommitdiff
path: root/ACE/ace/OS_NS_math.h
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2007-05-23 04:35:10 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2007-05-23 04:35:10 +0000
commitaadbae34c4bc753e584fd14002e82fe23ca59cff (patch)
tree480add712e978f96c02cfe8658635e6598f66a75 /ACE/ace/OS_NS_math.h
parent539a089b5751e7492ca63f69b9b7e3b63db82129 (diff)
downloadATCD-aadbae34c4bc753e584fd14002e82fe23ca59cff.tar.gz
ChangeLogTag:Tue May 23 05:12:04 2007 Ossama Othman <ossama othman at symantec dot com>
Diffstat (limited to 'ACE/ace/OS_NS_math.h')
-rw-r--r--ACE/ace/OS_NS_math.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/ACE/ace/OS_NS_math.h b/ACE/ace/OS_NS_math.h
index aa438d212f3..49143738a79 100644
--- a/ACE/ace/OS_NS_math.h
+++ b/ACE/ace/OS_NS_math.h
@@ -34,6 +34,7 @@
#endif
#define ACE_EXPORT_MACRO ACE_Export
+
/*
* We inline and undef some functions that may be implemented
* as macros on some platforms. This way macro definitions will
@@ -41,7 +42,6 @@
* using the pre-processor.
*
*/
-
inline double ace_log2_helper (double x)
{
#if defined (log2)
@@ -51,11 +51,38 @@ inline double ace_log2_helper (double x)
# if !defined (ACE_LACKS_LOG2)
return ACE_STD_NAMESPACE::log2 (x);
# else
- return log (x) / log (2.0);
+ /*
+ ==================================================================
+
+ log (x)
+ k
+ log (x) = -------
+ b log (b)
+ k
+
+ meaning the binary logarithm of x using the natural logarithm, for
+ example, is:
+
+
+ log (x)
+ e
+ log (x) = -------
+ 2 log (2)
+ e
+
+ ==================================================================
+ */
+
+ // Precomputed value of 1/log(2.0). Saves an expensive division and
+ // computing log(2.0) in each call.
+ double const _1_ln2 = 1.442695040888963407359924681002;
+
+ return log (x) * _1_ln2;
# endif /* !ACE_LACKS_LOG2 */
#endif /* defined (log2) */
}
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE_OS
@@ -68,7 +95,7 @@ namespace ACE_OS
ACE_NAMESPACE_INLINE_FUNCTION
double ceil (double x);
- /// This method computes base-2 logarithm of x
+ /// This method computes the base-2 logarithm of x.
ACE_NAMESPACE_INLINE_FUNCTION
double log2 (double x);