mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Introduce single_bit() helper
Self-documenting code instead of a tricky bitwise tweak, not known by everybody. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -207,6 +207,14 @@ inline Bitboard same_color_squares(Square s) {
|
||||
}
|
||||
|
||||
|
||||
/// single_bit() returns true if in the 'b' bitboard is set a single bit (or if
|
||||
/// b == 0).
|
||||
|
||||
inline bool single_bit(Bitboard b) {
|
||||
return !(b & (b - 1));
|
||||
}
|
||||
|
||||
|
||||
/// first_1() finds the least significant nonzero bit in a nonzero bitboard.
|
||||
/// pop_1st_bit() finds and clears the least significant nonzero bit in a
|
||||
/// nonzero bitboard.
|
||||
|
||||
Reference in New Issue
Block a user