Skip to content

Commit efd9ca7

Browse files
Add further detail about accuracy of value_from_loc bit manipulations
1 parent 64fb326 commit efd9ca7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,8 @@ impl<T: Counter> Histogram<T> {
12411241

12421242
#[inline]
12431243
fn value_from_loc(&self, bucket_index: u8, sub_bucket_index: u32) -> u64 {
1244-
// sum won't overflow; bucket_index and unit_magnitude are both <= 64
1244+
// sum won't overflow; bucket_index and unit_magnitude are both <= 64.
1245+
// However, the resulting shift may overflow if unit magnitude is large, for instance.
12451246
(sub_bucket_index as u64) << (bucket_index + self.unit_magnitude)
12461247
}
12471248

0 commit comments

Comments
 (0)