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
fix: off-by-one error in binary_count_trailing_zeros for zero input #14479
"The function returns 0 for a == 0, but mathematically, trailing zeros in binary representation of 0 are undefined (or conventionally treated as infinite). While log2(a & -a) fails for a=0, the current fallback to 0 is inconsistent with the documented behavior: binary_count_trailing_zeros(16) returns 4, but 0 has infinitely many trailing zeros — returning 0 is misleading and could cause bugs in algorithms relying on this (e.g., bit manipulation loops expecting correct trailing zero counts)."
Severity: high File: bit_manipulation/binary_count_trailing_zeros.py
Expected Behavior
This should be handled properly to prevent runtime errors or degraded reliability.
Activity
Dasmat13 commentedon Apr 14, 2026
Hi! I would like to work on this issue.
anup-sys commentedon Apr 23, 2026
Hello I will try to fix it