CMS 3D CMS Logo

isFinite.h
Go to the documentation of this file.
1 #ifndef FWCORE_Utilities_isFinite_H
2 #define FWCORE_Utilities_isFinite_H
3 
4 namespace edm {
5  template <typename T>
6  constexpr bool isFinite(T x);
7 
8  template <typename T>
9  constexpr bool isNotFinite(T x) {
10  return !isFinite(x);
11  }
12 
13  template <>
14  constexpr bool isFinite(float x) {
15  const unsigned int mask = 0x7f800000;
16  union {
17  unsigned int l;
18  float d;
19  } v = {.d = x};
20  return (v.l & mask) != mask;
21  }
22 
23  template <>
24  constexpr bool isFinite(double x) {
25  const unsigned long long mask = 0x7FF0000000000000LL;
26  union {
27  unsigned long long l;
28  double d;
29  } v = {.d = x};
30  return (v.l & mask) != mask;
31  }
32 
33  template <>
34  constexpr bool isFinite(long double x) {
35  double xx = x;
36  return isFinite(xx);
37  }
38 
39 } // namespace edm
40 
41 #endif // FWCORE_Utilities_isFinite_H
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
constexpr bool isFinite(T x)
constexpr uint32_t mask
Definition: gpuClustering.h:26
d
Definition: ztail.py:151
HLT enums.
float x
long double T