Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

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 (#12914)
  • Loading branch information
apopiak committed Dec 14, 2022
1 parent 89498c0 commit b65c9f0
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 b65c9f0

Please sign in to comment.