You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/17 20:25:02 UTC

[GitHub] [arrow] edponce commented on a change in pull request #10349: ARROW-12744: [C++][Compute] Add rounding kernel

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



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -355,6 +355,32 @@ struct PowerChecked {
   }
 };
 
+struct Round {
+  template <typename T, typename Arg>
+  static constexpr enable_if_floating_point<T> Call(KernelContext*, Arg arg, Status*) {
+    return std::round(arg);
+  }
+
+  template <typename T, typename Arg>
+  static constexpr enable_if_integer<T> Call(KernelContext*, Arg arg, Status*) {
+    return arg;
+  }
+};
+
+struct RoundChecked {
+  template <typename T, typename Arg>
+  static constexpr enable_if_integer<T> Call(KernelContext*, Arg arg, Status*) {
+    static_assert(std::is_same<T, Arg>::value, "");
+    return arg;
+  }
+
+  template <typename T, typename Arg>
+  static constexpr enable_if_floating_point<T> Call(KernelContext*, Arg arg, Status*) {
+    static_assert(std::is_same<T, Arg>::value, "");

Review comment:
       I knew this comment was coming with PR as is. This is currently a placeholder for the cases where if the rounding options suggest to round to nearest integer and output will be of integral type, then overflow/underflow can occur.




-- 
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:
users@infra.apache.org