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

Commit b65c9f0

Browse files
authored
add numerator and denominator to Rational128 Debug impl and increase precision of float representation (#12914)
1 parent 89498c0 commit b65c9f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

primitives/arithmetic/src/rational.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ pub struct Rational128(u128, u128);
9494
#[cfg(feature = "std")]
9595
impl sp_std::fmt::Debug for Rational128 {
9696
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
97-
write!(f, "Rational128({:.4})", self.0 as f32 / self.1 as f32)
97+
write!(f, "Rational128({} / {} ≈ {:.8})", self.0, self.1, self.0 as f64 / self.1 as f64)
9898
}
9999
}
100100

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

0 commit comments

Comments
 (0)