From 7f1c463ad86c82a19bd7792460f8d84f2eca9e18 Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Sat, 13 Jun 2020 20:08:34 +0200 Subject: [PATCH] Trimming trailing zeroes for numbers < 0. --- kalk_cli/src/output.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kalk_cli/src/output.rs b/kalk_cli/src/output.rs index 25bc363..0e37679 100644 --- a/kalk_cli/src/output.rs +++ b/kalk_cli/src/output.rs @@ -16,7 +16,11 @@ pub fn eval(parser: &mut parser::Context, input: &str) { let num = if exp <= 0 { // 0 < x < 1 - format!("0.{}{}", "0".repeat(exp.abs() as usize), digits) + format!( + "0.{}{}", + "0".repeat(exp.abs() as usize), + digits.trim_end_matches('0') + ) } else if use_sci_notation || result.fract() != 0 { // Insert the comma if there are supposed to be decimals. let mut chars: Vec = digits