decimal icon indicating copy to clipboard operation
decimal copied to clipboard

Two d128 values are equal, but their hashes aren't

Open spektom opened this issue 3 years ago • 0 comments

Here's reproduction:

let d1 = d128::from_str("0.12342342000000000").unwrap();
let d2 = d128::from_str("0.12342342").unwrap();
assert_eq!(d1, d2); // Succeeds

let mut hasher1 = DefaultHasher::new();
d1.hash(&mut hasher1);
let h1 = hasher1.finish();

let mut hasher2 = DefaultHasher::new();
d2.hash(&mut hasher2);
let h2 = hasher2.finish();

assert_eq!(h1, h2); // Crashes on 'assertion failed: `(left == right)` left: `14437253609867582409`, right: `1217654567999082045`'

spektom avatar Mar 05 '21 06:03 spektom