We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c3480e commit 7f736fbCopy full SHA for 7f736fb
cpp/src/arrow/util/bit_util.h
@@ -167,10 +167,8 @@ constexpr int64_t CoveringBytes(int64_t offset, int64_t length) {
167
168
// Returns the 'num_bits' least-significant bits of 'v'.
169
static inline uint64_t TrailingBits(uint64_t v, int num_bits) {
170
- if (ARROW_PREDICT_FALSE(num_bits == 0)) return 0;
171
if (ARROW_PREDICT_FALSE(num_bits >= 64)) return v;
172
- int n = 64 - num_bits;
173
- return (v << n) >> n;
+ return ((v >> num_bits) << num_bits) ^ v;
174
}
175
176
/// \brief Count the number of leading zeros in an unsigned integer.
0 commit comments