edponce commented on a change in pull request #10349:
URL: https://github.com/apache/arrow/pull/10349#discussion_r703275754
##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -856,10 +860,23 @@ struct LogbChecked {
struct RoundUtil {
template <typename T>
- static enable_if_t<std::is_floating_point<T>::value, bool> ApproxHalfInt(
- const T val, const T atol = 1e-5) {
- // |frac| ~ 0.5?
- return std::fabs(std::fmod(std::fabs(val), T(1)) - T(0.5)) <=
std::fabs(atol);
+ static constexpr enable_if_t<std::is_floating_point<T>::value, bool>
IsApproxEqual(
+ const T a, const T b, const T atol = kDefaultAbsoluteTolerance) {
+ return std::fabs(a - b) <= std::fabs(atol);
Review comment:
Just playing it safe. Although most implementations do not make use of
an absolute tolerance and simply compare directly against 0.5, but I found
special cases where it fails. This parameter can be controlled via Options but
it depends on the magnitude of the values being rounded.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]