From 1d633c538ea2d19d5bcbe31c2233ac150419da45 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Mon, 5 Aug 2019 17:56:10 +0200 Subject: [PATCH] Implemented numeric limits for floating point --- utils.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils.hpp b/utils.hpp index e02b4f1..d9a7f93 100644 --- a/utils.hpp +++ b/utils.hpp @@ -5,6 +5,7 @@ #define __STDC_VERSION__ 201112L #endif +#include #include namespace uart { @@ -121,20 +122,20 @@ struct NumericLimits { template <> struct NumericLimits { - template static constexpr float min() { static_assert(always_false_v, "Not implemented"); return 0; } - template static constexpr float max() { static_assert(always_false_v, "Not implemented"); return 0; } + template static constexpr float min() { return FLT_MIN; } + template static constexpr float max() { return FLT_MAX; } }; template <> struct NumericLimits { - template static constexpr double min() { static_assert(always_false_v, "Not implemented"); return 0; } - template static constexpr double max() { static_assert(always_false_v, "Not implemented"); return 0; } + template static constexpr double min() { return DBL_MIN; } + template static constexpr double max() { return DBL_MAX; } }; template <> struct NumericLimits { - template static constexpr long double min() { static_assert(always_false_v, "Not implemented"); return 0; } - template static constexpr long double max() { static_assert(always_false_v, "Not implemented"); return 0; } + template static constexpr long double min() { return LDBL_MIN; } + template static constexpr long double max() { return LDBL_MAX; } }; // clang-format on