Function alcibiades::bitsets::above_lsb_including
[−]
[src]
pub fn above_lsb_including(x: Bitboard) -> Bitboard
Returns a mask with all bits above and including the LSB set to
1
.
The way to calculate this is: above_lsb_including = x | -x;
.
If x
is 0
this function returns 0
.
Examples:
assert_eq!(above_lsb_including(0b10100), !0b11); assert_eq!(above_lsb_including(0), 0);
x | -x = above_lsb_including(x)
. . . . . . . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
. . 1 . 1 . . . 1 1 . 1 . 1 1 1 1 1 1 1 1 1 1 1
. 1 . . . 1 . . 1 . 1 1 1 . 1 1 1 1 1 1 1 1 1 1
. . . . . . . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
. 1 . . . 1 . . | 1 . 1 1 1 . 1 1 = 1 1 1 1 1 1 1 1
. . 1 . 1 . . . . . 1 1 . 1 1 1 . . 1 1 1 1 1 1
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .