Skip to content

Commit

Permalink
add numerator and denominator to Rational128 Debug impl and increase …
Browse files Browse the repository at this point in the history
…precision of float representation (paritytech#12914)
  • Loading branch information
apopiak authored and ark0f committed Feb 27, 2023
1 parent a6bc7a4 commit 19b0636
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions primitives/arithmetic/src/rational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ pub struct Rational128(u128, u128);
#[cfg(feature = "std")]
impl sp_std::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
write!(f, "Rational128({:.4})", self.0 as f32 / self.1 as f32)
write!(f, "Rational128({} / {} ≈ {:.8})", self.0, self.1, self.0 as f64 / self.1 as f64)
}
}

#[cfg(not(feature = "std"))]
impl sp_std::fmt::Debug for Rational128 {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
write!(f, "Rational128(..)")
write!(f, "Rational128({} / {})", self.0, self.1)
}
}

Expand Down

0 comments on commit 19b0636

Please sign in to comment.