mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Change floating point constant to mem::transmute u64 comparison
This commit is contained in:
parent
8907cbc0b8
commit
0dd13b0db2
1 changed files with 4 additions and 2 deletions
|
@ -92,8 +92,10 @@ impl PartialEq for Constant {
|
|||
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
|
||||
// `Fw32 == Fw64` so don’t 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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue