diff --git a/src/formatting.rs b/src/formatting.rs index bf321bc..5d492ab 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -52,7 +52,7 @@ impl StrExt for str { } pub fn get_significant_digits(n: &Float) -> usize { - let raw_string = n.to_string().replace('.', ""); + let raw_string = n.to_string().replace(['.', '-'], ""); let mut consecutive_zeros = 0; let mut consecutive_nines = 0; @@ -119,6 +119,11 @@ mod tests { ); } + #[test] + fn minus() { + assert_eq!(pretty_eval("-11", MAX_DIGITS).unwrap(), "-11"); + } + #[test] fn basic_get_significant_digits() { let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");