aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/habit/float.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/habit/float.rs b/src/habit/float.rs
index 7e98b18..2d61fc0 100644
--- a/src/habit/float.rs
+++ b/src/habit/float.rs
@@ -45,7 +45,13 @@ impl fmt::Display for FloatData {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 let characteristic = self.value / (10 * self.precision as u32); 46 let characteristic = self.value / (10 * self.precision as u32);
47 let mantissa = self.value % (10 * self.precision as u32); 47 let mantissa = self.value % (10 * self.precision as u32);
48 let s = format!("{}.{}", characteristic, mantissa); 48 let s = if characteristic == 0 {
49 format!(".{}", mantissa)
50 } else if mantissa == 0 {
51 format!("{}", characteristic)
52 } else {
53 format!("{}.{}", characteristic, mantissa)
54 };
49 write!(f, "{:^3}", s) 55 write!(f, "{:^3}", s)
50 } 56 }
51} 57}