summaryrefslogtreecommitdiff
path: root/ACE/ace/OS_NS_math.inl
blob: ff368b53c0dd425298910789470f42f6c08e51e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// -*- C++ -*-
//
// $Id$

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE_OS {

  ACE_INLINE double
  floor (double x)
  {
#if defined (ACE_LACKS_FLOOR)
    // This method computes the largest integral value not greater than x.
    if(x > 0)
      return static_cast<long> (x);
    else if ((static_cast<long> (x) < x) || (static_cast<long> (x) > x) )
      return static_cast<long>(x) - 1;
    else
      return x;
#else
    return ::floor (x);
#endif
  }

  ACE_INLINE double
  ceil (double x)
  {
#if defined (ACE_LACKS_CEIL)
    // This method computes the smallest integral value not less than x.
    if (x < 0)
      return static_cast<long> (x);
    else if ((static_cast<long> (x) < x) || (static_cast<long> (x) > x))
      return static_cast<long> (x) + 1;
    else
      return x;
#else
    return ::ceil (x);
#endif
  }

  ACE_INLINE double
  log2 (double x)
  {
    return ace_log2_helper (x);
  }

} // ACE_OS namespace

ACE_END_VERSIONED_NAMESPACE_DECL