From 1ee9bc8ca43e6c752414de2ee4fb9f2d6d62b75b Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 7 Aug 2019 19:59:48 +0200 Subject: [PATCH] Removed sign from maxNumDigits, because sign is handled separately anyway --- uart.hpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/uart.hpp b/uart.hpp index c56f541..8e199ef 100644 --- a/uart.hpp +++ b/uart.hpp @@ -36,18 +36,6 @@ static constexpr size_t maxNumDigits() constexpr T minVal = util::NumericLimits::min(); constexpr T maxVal = util::NumericLimits::max(); - T minDigits = cntDigits() + ((minVal < 0) ? 1 : 0); - T maxDigits = cntDigits() + ((maxVal < 0) ? 1 : 0); - - return (minDigits < maxDigits) ? maxDigits : minDigits; -} - -template -static constexpr size_t maxPadding() -{ - constexpr T minVal = util::NumericLimits::min(); - constexpr T maxVal = util::NumericLimits::max(); - T minDigits = cntDigits(); T maxDigits = cntDigits(); @@ -125,9 +113,9 @@ class Uart { static void txNumber(const T &val) { static_assert(util::is_integral_v, "Only supported on integral types"); - static_assert(Base >= 2, "Numbers with bases less than 2 make no sense"); - static_assert(Base <= 16, "Numbers with bases higher than 16 are not supported"); - static_assert(Padding <= detail::maxPadding(), "Cannot pad more than maximum length of number"); + static_assert(Base >= 2, "Numbers with base less than 2 make no sense"); + static_assert(Base <= 16, "Numbers with base higher than 16 are not supported"); + static_assert(Padding <= detail::maxNumDigits(), "Cannot pad more than maximum length of number"); constexpr char alphaChar = (LowerCase) ? 'a' : 'A'; constexpr size_t numDigits = detail::maxNumDigits();