cyb70289 commented on a change in pull request #10274:
URL: https://github.com/apache/arrow/pull/10274#discussion_r630683291



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -66,6 +66,50 @@ constexpr Unsigned to_unsigned(T signed_) {
   return static_cast<Unsigned>(signed_);
 }
 
+struct AbsoluteValue {
+  template <typename T, typename Arg>
+  static constexpr enable_if_floating_point<T> Call(KernelContext*, Arg arg, 
Status*) {
+    return (arg < static_cast<T>(0)) ? -arg : arg;

Review comment:
       Any reason don't use `std::fabs` directly?
   std::fabs provides more optimized code: https://godbolt.org/z/P84WbxvGP
   std::fabs(-0.0) = 0.0, but `(x < 0) ? -x : x` outputs -0.0 if x = -0.0.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to