Permalink
Browse files

Changed missing() float or double to infinity instead of nan. Nan det…

…ection fails on some compilers, (e.g.: gcc, clang 3.9) when fast-math is enabled. See https://stackoverflow.com/a/42138465/2958741.
  • Loading branch information...
giuliomoro committed Jan 11, 2019
1 parent 0e35132 commit c4041ba585d70f6123658af8dcc10beb2fdbfa9c
Showing with 5 additions and 17 deletions.
  1. +5 −17 Source/Utility/Types.h
@@ -78,24 +78,12 @@ template<> struct missing_value<unsigned long long> {
static const bool isMissing(unsigned long long val) { return (val == missing()); }
};
template<> struct missing_value<float> {
static const float missing() { return std::numeric_limits<float>::quiet_NaN(); }
static const bool isMissing(float val) {
#ifdef _MSC_VER
return (_isnan(val) != 0);
#else
return std::isnan(val);
#endif
}
static const float missing() { return std::numeric_limits<float>::infinity(); }
static const bool isMissing(float val) { return val == missing(); }
};
template<> struct missing_value<double> {
static const double missing() { return std::numeric_limits<double>::quiet_NaN(); }
static const bool isMissing(double val) {
#ifdef _MSC_VER
return (_isnan(val) != 0);
#else
return std::isnan(val);
#endif
}
static const double missing() { return std::numeric_limits<double>::infinity(); }
static const bool isMissing(double val) { return val == missing(); }
};
template<typename T1, typename T2>
struct missing_value<std::pair<T1,T2> > {
@@ -135,4 +123,4 @@ typedef double timestamp_diff_type;
#endif /* FIXED_POINT_TIME */


#endif /* KEYCONTROL_TYPES_H */
#endif /* KEYCONTROL_TYPES_H */

0 comments on commit c4041ba

Please sign in to comment.