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  bool isFinite(T x);
7 
8  template <typename T>
9  inline
10  bool isNotFinite(T x) {
11  return !isFinite(x);
12  }
13 
14  template<>
15  inline
16  bool isFinite(float x) {
17  const unsigned int mask = 0x7f800000;
18  union { unsigned int l; float d;} v;
19  v.d =x;
20  return (v.l&mask)!=mask;
21  }
22 
23  template<>
24  inline
25  bool isFinite(double x) {
26  const unsigned long long mask = 0x7FF0000000000000LL;
27  union { unsigned long long l; double d;} v;
28  v.d =x;
29  return (v.l&mask)!=mask;
30  }
31 
32  template<>
33  inline
34  bool isFinite(long double x) {
35  double xx=x;
36  return isFinite(xx);
37  }
38 
39 }
40 
41 #endif // FWCORE_Utilities_isFinite_H
42 
bool isFinite(T x)
bool isNotFinite(T x)
Definition: isFinite.h:10
HLT enums.
long double T