From 46c697234cc5eaaf4fb6b9ed3f66076998ea36f1 Mon Sep 17 00:00:00 2001 From: electria Date: Wed, 30 Sep 2026 20:07:15 -0700 Subject: [PATCH] feat: cap significant_digits to 10 in pretty_eval --- src/formatting.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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$}{}",