Skip to content

Commit

Permalink
Round the number of hash functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Nov 5, 2024
1 parent 2acb4f8 commit 4c742d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<T: ?Sized> Bloom<T> {
fn optimal_k_num(bitmap_bits: u64, items_count: usize) -> u32 {
let m = bitmap_bits as f64;
let n = items_count as f64;
let k_num = (m / n * f64::ln(2.0f64)).ceil() as u32;
let k_num = (m / n * f64::ln(2.0f64)).round() as u32;
cmp::max(k_num, 1)
}

Expand Down

0 comments on commit 4c742d8

Please sign in to comment.