diff --git a/src/main.rs b/src/main.rs index a056ef6..c9921ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ pub fn get_significant_digits(n: &Float) -> usize { let mut significant_digits = raw_string.len() - 1; let mut consecutive_zeros = 0; + let mut consecutive_nines = 0; for (i, c) in raw_string.char_indices() { if c == '0' { consecutive_zeros += 1; @@ -24,9 +25,18 @@ pub fn get_significant_digits(n: &Float) -> usize { consecutive_zeros = 0; } + if c == '9' { + consecutive_nines += 1; + } else { + consecutive_nines = 0; + } + if consecutive_zeros >= 10 { significant_digits = i - consecutive_zeros; break; + } else if consecutive_nines >= 10 { + significant_digits = i - consecutive_nines; + break; } if !raw_string[i..raw_string.len()].contains(|c| matches!(c, '1'..'9')) {