edponce commented on a change in pull request #10016:
URL: https://github.com/apache/arrow/pull/10016#discussion_r614470384



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -233,6 +235,43 @@ struct DivideChecked {
   }
 };
 
+struct Negate {
+  template <typename T, typename Arg0>
+  // NOTE [EPM]: Discuss on 0 vs. -0.
+  static constexpr enable_if_floating_point<T> Call(KernelContext*, Arg0 arg) {
+    return -arg;
+  }
+
+  // NOTE [EPM]: How to handle unsigned integers?
+  //  * Promote to signed?

Review comment:
       After careful deliberation on this topic, I think negate should preserve 
data type. Also, in a mathematical context, negation is not supported for 
unsigned integrals, so I do not think kernels should be available for the 
"checked" kernels. For default kernels behavior is to wrap around (apply two's 
complement in a safe manner).




-- 
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