From a338f657d59d15ca48b5641d243c9db72120f0e5 Mon Sep 17 00:00:00 2001 From: chertus Date: Fri, 3 Aug 2018 19:32:55 +0300 Subject: [PATCH] unari arithm operations for decimal (partial support) --- dbms/src/Functions/FunctionsArithmetic.h | 62 +++++++++++++++---- .../00700_decimal_arithm.reference | 3 + .../0_stateless/00700_decimal_arithm.sql | 2 + 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/dbms/src/Functions/FunctionsArithmetic.h b/dbms/src/Functions/FunctionsArithmetic.h index 0e664709c38..64a4e2a04f0 100644 --- a/dbms/src/Functions/FunctionsArithmetic.h +++ b/dbms/src/Functions/FunctionsArithmetic.h @@ -602,7 +602,9 @@ struct AbsImpl static inline ResultType apply(A a) { - if constexpr (std::is_integral_v && std::is_signed_v) + if constexpr (std::is_same_v) + return a < 0 ? -a : a; + else if constexpr (std::is_integral_v && std::is_signed_v) return a < 0 ? static_cast(~a) + 1 : a; else if constexpr (std::is_integral_v && std::is_unsigned_v) return static_cast(a); @@ -1238,6 +1240,9 @@ struct FunctionUnaryArithmeticMonotonicity; template