math.h
Go to the documentation of this file.
1 
11 #pragma once
12 #include "interop/config.h"
13 #include <limits>
14 
15 #include <cmath>
16 #if defined(HAVE_NO_STD_ISNAN)
17 # if defined(HAVE_ISNAN)
18 # include <math.h>
19  #elif defined(HAVE___ISNAN)
20 # include <math.h>
21  #elif defined(HAVE_FLOAT_H_ISNAN)
22 # include <float.h>
23  #endif
24  namespace std
25  {
31  template<typename T>
32  bool isnan(const T val)
33  {
34 # if defined(HAVE_ISNAN)
35  return ::isnan(val);
36 # elif defined(HAVE___ISNAN)
37  return __isnan(val);
38 # elif defined(HAVE_FLOAT_H_ISNAN)
39  return _isnan(val);
40 # else
41  return val != val;
42 #endif
43  }
49  template<typename T>
50  bool isinf(const T val)
51  {
52 # if defined(HAVE_ISNAN)
53  return ::isinf(val);
54 # elif defined(HAVE___ISNAN)
55  return __isinf(val);
56 # elif defined(HAVE_FLOAT_H_ISNAN)
57  return _isinf(val);
58 # else
59  return !isnan(val) && isnan(val-val);
60 #endif
61  }
62  }
63 #endif
64 
65 namespace illumina { namespace interop { namespace util
66 {
76  template<typename T>
77  float float_cast(const T val, const T sentinel = std::numeric_limits<T>::max())
78  {
79  if (val == sentinel)
80  return std::numeric_limits<float>::quiet_NaN();
81  return static_cast<float>(val);
82  }
83 }}}
Definition: enum_description.h:15
Definition: enums.h:301
float float_cast(const T val, const T sentinel=std::numeric_limits< T >::max())
Definition: math.h:77