fix(formatting): don't count minus as digit
This commit is contained in:
parent
12455924e1
commit
475c30b1a9
1 changed files with 6 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ impl StrExt for str {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_significant_digits(n: &Float) -> usize {
|
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_zeros = 0;
|
||||||
let mut consecutive_nines = 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]
|
#[test]
|
||||||
fn basic_get_significant_digits() {
|
fn basic_get_significant_digits() {
|
||||||
let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");
|
let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue