diff --git a/src/formatting.rs b/src/formatting.rs index bb67376..b7b6a58 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -4,6 +4,7 @@ use crate::nodes::{self, Error}; pub fn pretty_eval(input: &str, max_digits: usize) -> Result { let (prefix, deliminator, input) = input.rsplit_once_last(&["= ", "& ", "plus.minus "]); + let input = input.replace('_', ""); // no need to remove the character here, // as we ignore it in all other logic already @@ -134,6 +135,11 @@ mod tests { assert_pretty_eval!("plus.minus 5 & = 5"); } + #[test] + fn underscore_input() { + assert_pretty_eval!("10_000 * 10_000 * 4", "4 * 10^8") + } + #[test] fn basic_get_significant_digits() { let many_zeros = eval("14.00643 + 1.00784 * 4 + 35.446 + 15.9994 * 4");