48 static inline bool IsFiniteD(
double val)
50 return std::isfinite(val);
61 template <>
inline bool IsFiniteT<float>(
float value)
63 return std::isfinite(value);
66 template <>
inline bool IsFiniteT<double>(
double value)
68 return std::isfinite(value);
71 template <>
inline bool IsFiniteT<long double>(
long double value)
73 return std::isfinite(
static_cast<double>(value));
79 template <
typename T>
inline bool IsNanT(T )
84 template <>
inline bool IsNanT<float>(
float value)
86 return std::isnan(value);
89 template <>
inline bool IsNanT<double>(
double value)
91 return std::isnan(value);
94 template <>
inline bool IsNanT<long double>(
long double value)
96 return std::isnan(
static_cast<double>(value));
103 static inline std::int32_t RoundD2I(
double d)
105 return d>0 ? (int)(d+0.5) : (int)(d-0.5);
120 template <
typename T>
127 if (!std::numeric_limits<T>::is_integer)
128 return static_cast<T
>(value);
141 if (value <= (
double)std::numeric_limits<T>::min())
142 return std::numeric_limits<T>::min();
143 if (value >= (
double)std::numeric_limits<T>::max())
144 return std::numeric_limits<T>::max();
149 return static_cast<T
>(value - 0.5);
150 return static_cast<T
>(value + 0.5);
157 template <
typename T>
160 if (!std::numeric_limits<T>::is_integer)
161 return static_cast<T
>(value);
165 return RoundAndClip<T>(value);