Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Nov 2, 2024
1 parent 2d16f29 commit 233318a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
5 changes: 1 addition & 4 deletions crates/libm-test/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ where

/// Helper to get the length of the period in unit `T`.
fn period() -> Option<T> {
if Self::PERIODIC.is_none() {
return None;
}

Self::PERIODIC?;
let start = Self::period_start();
let end = Self::period_end();
if start > end { Some(start - end) } else { Some(end - start) }
Expand Down
35 changes: 13 additions & 22 deletions crates/libm-test/src/f8_impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unusual_byte_groupings)]

use std::cmp::{self, Ordering};
use std::{fmt, ops};

Expand Down Expand Up @@ -439,30 +441,19 @@ impl cmp::PartialOrd for f8 {

let a_srep = self.to_bits_signed();
let b_srep = other.to_bits_signed();
let res = a_srep.cmp(&b_srep);

// If at least one of a and b is positive, we get the same result comparing
// a and b as signed integers as we would with a fp_ting-point compare.
let res = if a_srep & b_srep >= 0 {
if a_srep < b_srep {
Ordering::Less
} else if a_srep == b_srep {
Ordering::Equal
} else {
Ordering::Greater
}
// Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a
// sign-magnitude representation, then this flip is incorrect).
} else if a_srep > b_srep {
Ordering::Less
} else if a_srep == b_srep {
Ordering::Equal
if a_srep & b_srep >= 0 {
// If at least one of a and b is positive, we get the same result comparing
// a and b as signed integers as we would with a fp_ting-point compare.
Some(res)
} else {
Ordering::Greater
};

Some(res)
// Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a
// sign-magnitude representation, then this flip is incorrect).
Some(res.reverse())
}
}
}
impl fmt::Display for f8 {
Expand Down

0 comments on commit 233318a

Please sign in to comment.