You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python][C++][Compute] logb(0, base) returns -inf for every base, including 0 < base < 1 and NaN #55636
Describe the bug, including details regarding any error messages, version, and platform.
Logb in cpp/src/arrow/compute/kernels/scalar_arithmetic.cc special-cases x == 0.0 and returns -inf for every base that is not zero or negative:
if (x == 0.0) {
if (base == 0.0 || base < 0.0) {
return std::numeric_limits<T>::quiet_NaN();
} else {
return -std::numeric_limits<T>::infinity();
}
}
That is only right for base > 1. For 0 < base < 1, log(base) is negative, so log_base(0) is +inf. A NaN base should give NaN, and an infinite base gives -inf / inf, which is NaN.
Without the special case, std::log(x) / std::log(base) already gives the right values here, since std::log(0.0) is -inf. The x < 0.0 branch is also covered by std::log returning NaN. So one fix is to drop the x == 0.0 branch, or make it return -inf / std::log(base). logb_checked raises for x == 0 and is not affected.
changed the title [-][C++][Compute] logb(0, base) returns -inf for every base, including 0 < base < 1 and NaN[/-][+][Python][C++][Compute] logb(0, base) returns -inf for every base, including 0 < base < 1 and NaN[/+]on Nov 16, 2026
Activity
[-][C++][Compute] logb(0, base) returns -inf for every base, including 0 < base < 1 and NaN[/-][+][Python][C++][Compute] logb(0, base) returns -inf for every base, including 0 < base < 1 and NaN[/+]