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
|
#define __STDC_VERSION__ 201112L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
namespace uart {
|
namespace uart {
|
||||||
@ -121,20 +122,20 @@ struct NumericLimits<unsigned long long int> {
|
|||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct NumericLimits<float> {
|
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 min() { return FLT_MIN; }
|
||||||
template <typename... Ts> static constexpr float max() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
template <typename... Ts> static constexpr float max() { return FLT_MAX; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct NumericLimits<double> {
|
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 min() { return DBL_MIN; }
|
||||||
template <typename... Ts> static constexpr double max() { static_assert(always_false_v<Ts...>, "Not implemented"); return 0; }
|
template <typename... Ts> static constexpr double max() { return DBL_MAX; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct NumericLimits<long double> {
|
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 min() { return LDBL_MIN; }
|
||||||
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 max() { return LDBL_MAX; }
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user