Change floating point constant to mem::transmute u64 comparison

This commit is contained in:
Taylor Cramer 2016-07-13 00:59:35 -07:00
parent 8907cbc0b8
commit 0dd13b0db2

View file

@ -92,8 +92,10 @@ impl PartialEq for Constant {
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
// `Fw32 == Fw64` so dont compare them
match (ls.parse::<f64>(), rs.parse::<f64>()) {
(Ok(l), Ok(r)) => l.eq(&r) &&
(l.is_sign_positive() == r.is_sign_positive()), // needed for 0.0 != -0.0
// mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs
(Ok(l), Ok(r)) => unsafe {
mem::transmute::<f64, u64>(l) == mem::transmute::<f64, u64>(r)
},
_ => false,
}
}