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 2022/07/13 11:44:34 UTC

[GitHub] [arrow] projjal commented on a diff in pull request #13568: ARROW-17036: [C++][Gandiva] Add sign Function

projjal commented on code in PR #13568:
URL: https://github.com/apache/arrow/pull/13568#discussion_r919980057


##########
cpp/src/gandiva/precompiled/arithmetic_ops.cc:
##########
@@ -469,6 +469,28 @@ BITWISE_NOT(int64)
 #undef DATE_TYPES
 #undef NUMERIC_BOOL_DATE_TYPES
 #undef NUMERIC_DATE_TYPES
+
+#define SIGN(TYPE)                         \
+  FORCE_INLINE                             \
+  gdv_##TYPE sign_##TYPE(gdv_##TYPE in1) { \
+    gdv_##TYPE out;                        \
+    if (in1 > 0) {                         \
+      out = static_cast<gdv_##TYPE>(1);    \
+    } else if (in1 < 0) {                  \
+      out = static_cast<gdv_##TYPE>(-1);   \
+    } else {                               \
+      out = static_cast<gdv_##TYPE>(0);    \

Review Comment:
   instead of returning 0 return in1..this would take care of NaN. Also add unit tests for +infy, -infy, nan, 0.0f and -0.0f



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

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org