diff options
author | Patrick Simianer <p@simianer.de> | 2012-03-13 09:24:47 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2012-03-13 09:24:47 +0100 |
commit | c3a9ea64251605532c7954959662643a6a927bb7 (patch) | |
tree | fed6048a5acdaf3834740107771c2bc48f26fd4d /utils/nan.h | |
parent | 867bca3e5fa0cdd63bf032e5859fb5092d9a4ca1 (diff) | |
parent | a45af4a3704531a8382cd231f6445b3a33b598a3 (diff) |
merge with upstream
Diffstat (limited to 'utils/nan.h')
-rwxr-xr-x | utils/nan.h | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/utils/nan.h b/utils/nan.h deleted file mode 100755 index 257364d5..00000000 --- a/utils/nan.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef NAN_H -#define NAN_H -//TODO: switch to C99 isnan isfinite isinf etc. (faster) - -#include <limits> - -template <bool> struct nan_static_assert; -template <> struct nan_static_assert<true> { }; - -// is_iec559 i.e. only IEEE 754 float has x != x <=> x is nan -template<typename T> -inline bool is_nan(T x) { -// static_cast<void>(sizeof(nan_static_assert<std::numeric_limits<T>::has_quiet_NaN>)); - return std::numeric_limits<T>::has_quiet_NaN && (x != x); -} - -template <typename T> -inline bool is_inf(T x) { -// static_cast<void>(sizeof(nan_static_assert<std::numeric_limits<T>::has_infinity>)); - return x == std::numeric_limits<T>::infinity() || x == -std::numeric_limits<T>::infinity(); -} - -template <typename T> -inline bool is_pos_inf(T x) { -// static_cast<void>(sizeof(nan_static_assert<std::numeric_limits<T>::has_infinity>)); - return x == std::numeric_limits<T>::infinity(); -} - -template <typename T> -inline bool is_neg_inf(T x) { -// static_cast<void>(sizeof(nan_static_assert<std::numeric_limits<T>::has_infinity>)); - return x == -std::numeric_limits<T>::infinity(); -} - -//c99 isfinite macro shoudl be much faster -template <typename T> -inline bool is_finite(T x) { - return !is_nan(x) && !is_inf(x); -} - - -#endif |