Skip to content

Commit

Permalink
first run of new table. BUGS
Browse files Browse the repository at this point in the history
  • Loading branch information
mikea committed Nov 11, 2024
1 parent d97e2e2 commit ef134af
Show file tree
Hide file tree
Showing 9 changed files with 973 additions and 514 deletions.
17 changes: 17 additions & 0 deletions src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ pub(crate) fn fill_ones_below_lowest_bit_set(x: u64) -> u64 {
debug_assert!(x != 0);
x | x.wrapping_sub(1)
}

#[inline]
pub(crate) fn extract_highest_bit_set(x: u64) -> u64 {
debug_assert!(x != 0);
1 << (63 - x.leading_zeros())
}

#[inline]
pub(crate) fn reset_highest_bit_set(x: u64) -> u64 {
debug_assert!(x != 0);
x & !extract_highest_bit_set(x)
}

#[inline]
pub(crate) fn mask_from_highest_bit_set(x: u64) -> u64 {
mask_up_to_lowest_bit_set(x.reverse_bits()).reverse_bits()
}
Loading

0 comments on commit ef134af

Please sign in to comment.