Implemented numeric limits for floating point
This commit is contained in:
parent
231fc0de48
commit
1d633c538e
13
utils.hpp
13
utils.hpp
@ -5,6 +5,7 @@
|
||||
#define __STDC_VERSION__ 201112L
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace uart {
|
||||
@ -121,20 +122,20 @@ struct NumericLimits<unsigned long long int> {
|
||||
|
||||
template <>
|
||||
struct NumericLimits<float> {
|
||||
template <typename... Ts> static constexpr float min() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr float max() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr float min() { return FLT_MIN; }
|
||||
template <typename... Ts> static constexpr float max() { return FLT_MAX; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct NumericLimits<double> {
|
||||
template <typename... Ts> static constexpr double min() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr double max() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr double min() { return DBL_MIN; }
|
||||
template <typename... Ts> static constexpr double max() { return DBL_MAX; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct NumericLimits<long double> {
|
||||
template <typename... Ts> static constexpr long double min() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr long double max() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
||||
template <typename... Ts> static constexpr long double min() { return LDBL_MIN; }
|
||||
template <typename... Ts> static constexpr long double max() { return LDBL_MAX; }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user