Skip to content

Commit 8cc280f

Browse files
marink2marink2fevangelista
authoredApr 19, 2024
Fix bitwise_operations.cc to address return value inconsistency (evangelistalab#378)
* fix bitwise_operations return value inconsistency * Update forte/sparse_ci/bitwise_operations.hpp Co-authored-by: fevangelista <[email protected]> --------- Co-authored-by: marink2 <[email protected]> Co-authored-by: fevangelista <[email protected]>
1 parent db40221 commit 8cc280f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎forte/sparse_ci/bitwise_operations.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ inline double ui64_bit_parity(uint64_t x) { return 1 - 2 * ((std::popcount(x) &
5555
/// @brief Bit-scan to find next set bit
5656
/// @param x the uint64_t integer to test
5757
/// @return the index of the least significant 1-bit of x, or if x is zero, returns ~0
58-
inline uint64_t ui64_find_lowest_one_bit(uint64_t x) { return std::countr_zero(x); }
58+
inline uint64_t ui64_find_lowest_one_bit(uint64_t x) {
59+
return (x == 0) ? ~uint64_t(0) : std::countr_zero(x);
60+
}
5961

6062
/// @brief Bit-scan to find next set bit after position pos
6163
/// @param x the uint64_t integer to test

0 commit comments

Comments
 (0)