From 9b623ea3943165fe7efb5e47a0b5b9452c1599e6 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 9 May 2018 00:09:55 +0200 Subject: 9.8 --- zen/basic_math.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'zen/basic_math.h') diff --git a/zen/basic_math.h b/zen/basic_math.h index 1b6b7e97..16f69bde 100755 --- a/zen/basic_math.h +++ b/zen/basic_math.h @@ -31,7 +31,7 @@ template T clampCpy(T val, T minVal, T maxVal); template //precondition: range must be sorted! auto nearMatch(const T& val, InputIterator first, InputIterator last); -int round(double d); //"little rounding function" +int64_t round(double d); //"little rounding function" template auto integerDivideRoundUp(N numerator, D denominator); @@ -182,7 +182,7 @@ std::pair minMaxElement(InputIterator first, Input } } } - return std::make_pair(lowest, largest); + return { lowest, largest }; } @@ -220,20 +220,20 @@ bool isNull(T value) inline -int round(double d) +int64_t round(double d) { - assert(d - 0.5 >= std::numeric_limits::min() && //if double is larger than what int can represent: - d + 0.5 <= std::numeric_limits::max()); //=> undefined behavior! - return static_cast(d < 0 ? d - 0.5 : d + 0.5); + assert(d - 0.5 >= std::numeric_limits::min() && //if double is larger than what int can represent: + d + 0.5 <= std::numeric_limits::max()); //=> undefined behavior! + return static_cast(d < 0 ? d - 0.5 : d + 0.5); } template inline auto integerDivideRoundUp(N numerator, D denominator) { - static_assert(std::is_integral::value && std::is_unsigned::value, ""); - static_assert(std::is_integral::value && std::is_unsigned::value, ""); - assert(denominator > 0); + static_assert(std::is_integral::value, ""); + static_assert(std::is_integral::value, ""); + assert(numerator > 0 && denominator > 0); return (numerator + denominator - 1) / denominator; } -- cgit