From 986e5412e03ecc991ba96706b5db49436bc73cd8 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 7 Oct 2019 09:26:18 +0100 Subject: [PATCH] Fix abs() usage for Ubuntu 18.04 abs(unsigned long long) is not a thing so Ubuntu 18.04 compiling fails. Using std::fabs() instead which handles this better (casts as double). --- utils/regr/moda.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/regr/moda.cpp b/utils/regr/moda.cpp index 180e21b2a..0e571e02e 100644 --- a/utils/regr/moda.cpp +++ b/utils/regr/moda.cpp @@ -304,8 +304,8 @@ mcsv1_UDAF::ReturnCode Moda_impl_T::evaluate(mcsv1Context* context, static_an else if (iter->second == maxCnt) { // Tie breaker: choose the closest to avg. If still tie, choose smallest - if ((abs(val-avg) > abs(iter->first-avg)) - || ((abs(val-avg) == abs(iter->first-avg)) && (abs(val) > abs(iter->first)))) + if ((std::fabs(val-avg) > std::fabs(iter->first-avg)) + || ((std::fabs(val-avg) == std::fabs(iter->first-avg)) && (std::fabs(val) > std::fabs(iter->first)))) { val = iter->first; }