From c1a4b1788b3dc539c580394fe06b9699e8868a47 Mon Sep 17 00:00:00 2001 From: Vla Mai Date: Tue, 2 Apr 2019 10:33:00 +0500 Subject: fix negative number print --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3816377..43f23ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,14 +110,14 @@ fn pprint(ans: f64) { fn thousand_sep(inp:&str) -> String{ let mut result_string = String::new(); for (i,c) in inp.to_string().chars().rev().enumerate(){ - if i % 3 == 0 && i != 0{ + if i % 3 == 0 && i != 0 && c.to_string() != "-"{ result_string.push_str(","); result_string.push(c); continue } result_string.push(c) } - let arrange:i16 = CONFIGURATION.fix as i16 - inp.len() as i16; + let arrange:i16 = CONFIGURATION.fix as i16 - result_string.len() as i16; if arrange > 0 { result_string.push_str(" ".repeat(arrange as usize).as_str()) -- cgit v1.2.3