diff --git a/src/formatting.rs b/src/formatting.rs index 034ce87..5292282 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -2,6 +2,8 @@ use rug::Float; use crate::nodes::{self, Error}; +pub const MAX_DIGITS: usize = 10; + pub fn pretty_eval(mut input: String) -> Result { // no need to remove the characters here, // as we ignore the them in all other logic already @@ -17,7 +19,7 @@ pub fn pretty_eval(mut input: String) -> Result { .is_some(); let result = nodes::eval(&input)?; - let significant_digits = get_significant_digits(&result); + let significant_digits = get_significant_digits(&result).min(MAX_DIGITS); Ok(format!( "{}{}{result:.significant_digits$}{}",