fix(formatting): don't count minus as digit

This commit is contained in:
electria 2026-10-18 22:14:57 -07:00
commit 475c30b1a9
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -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");