Fixed typos
[ACE_TAO.git] / ACE / ace / OS_NS_math.h
blob2072851f7f6b21199e8c5909d74018678a104d22
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_math.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 * Originally in OS.h.
13 //=============================================================================
15 #ifndef ACE_OS_NS_MATH_H
16 # define ACE_OS_NS_MATH_H
18 # include /**/ "ace/pre.h"
20 # include "ace/config-all.h"
22 # if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 # endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/os_include/os_math.h"
28 #include /**/ "ace/ACE_export.h"
30 #if defined (ACE_EXPORT_MACRO)
31 # undef ACE_EXPORT_MACRO
32 #endif
33 #define ACE_EXPORT_MACRO ACE_Export
37 * We inline and undef some functions that may be implemented
38 * as macros on some platforms. This way macro definitions will
39 * be usable later as there is no way to save the macro definition
40 * using the pre-processor.
42 inline double ace_log2_helper (double x)
44 #if defined (log2)
45 return log2 (x);
46 #undef log2
47 #else
48 # if !defined (ACE_LACKS_LOG2)
49 return ACE_STD_NAMESPACE::log2 (x);
50 # else
52 ==================================================================
54 log (x)
56 log (x) = -------
57 b log (b)
60 meaning the binary logarithm of x using the natural logarithm, for
61 example, is:
64 log (x)
66 log (x) = -------
67 2 log (2)
70 ==================================================================
73 // Precomputed value of 1/log(2.0). Saves an expensive division and
74 // computing log(2.0) in each call.
75 double const _1_ln2 = 1.442695040888963407359924681002;
77 return log (x) * _1_ln2;
78 # endif /* !ACE_LACKS_LOG2 */
79 #endif /* defined (log2) */
83 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
85 namespace ACE_OS
87 /// This method computes the largest integral value not greater than x.
88 template <typename T>
89 inline
90 T floor (T x)
92 return ACE_STD_NAMESPACE::floor (x);
95 #if defined (ACE_HAS_WINCE)
96 /// Windows CE has an intrinsic floor for float
97 template <>
98 inline
99 float floor (float x)
101 return ACE_STD_NAMESPACE::floorf (x);
103 #endif
105 /// This method computes the smallest integral value not less than x.
106 template <typename T>
107 inline
108 T ceil (T x)
110 return ACE_STD_NAMESPACE::ceil (x);
113 #if defined (ACE_HAS_WINCE)
114 /// Windows CE has an intrinsic ceil for float
115 template <>
116 inline
117 float ceil (float x)
119 return ACE_STD_NAMESPACE::ceilf (x);
121 #endif
123 /// This method computes the base-2 logarithm of x.
124 ACE_NAMESPACE_INLINE_FUNCTION
125 double log2 (double x);
127 } /* namespace ACE_OS */
129 ACE_END_VERSIONED_NAMESPACE_DECL
131 # if defined (ACE_HAS_INLINED_OSCALLS)
132 # if defined (ACE_INLINE)
133 # undef ACE_INLINE
134 # endif /* ACE_INLINE */
135 # define ACE_INLINE inline
136 # include "ace/OS_NS_math.inl"
137 # endif /* ACE_HAS_INLINED_OSCALLS */
139 # include /**/ "ace/post.h"
140 #endif /* ACE_OS_NS_MATH_H */