From 7a1049fda95d5e7bfc5f3b474707ad14d10a27ba Mon Sep 17 00:00:00 2001 From: electria Date: Sun, 15 Nov 2026 21:39:59 -0800 Subject: [PATCH] docs(formatting): add note --- src/formatting.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/formatting.rs b/src/formatting.rs index 8bc7cfc..d01539b 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -13,6 +13,13 @@ pub fn pretty_eval(input: &str, max_digits: usize) -> Result { let result = nodes::eval(&input)?; let display_digits = get_significant_digits(&result).clamp(1, max_digits); + // this helps improve the output formatting, + // by not using scientific notation when it doesn't make sense. + // + // it does this by parsing the string, which is unfortunate. + // ideally, this would be done by reimplementing the display code; + // but neither I nor Edeth know how to do that yet. + // (much like with `get_significant_digits`) let mut changing_string = format!("{result:.display_digits$}"); if let Some(index) = changing_string.find('e') && ((changing_string.chars().nth(index + 1).unwrap() == '-'