add numerator and denominator to Rational128 Debug impl and increase precision of float representation (#12914)

This commit is contained in:
Alexander Popiak
2022-12-14 10:59:04 +01:00
committed by GitHub
parent c0c8d6305f
commit 09ae802f9c
@@ -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)
}
}