From fc06e1e9813b7f2692110f718d61b749e7ecc579 Mon Sep 17 00:00:00 2001 From: electria Date: Thu, 16 Jul 2026 00:36:36 -0700 Subject: [PATCH] feat: add constant pi copy and pasted from ALEKS calculator, as I gave up trying to find what the best approximation to use would be. --- src/nodes/from_str.rs | 1 + src/nodes/tests.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/nodes/from_str.rs b/src/nodes/from_str.rs index 4f0f20d..f4b147d 100644 --- a/src/nodes/from_str.rs +++ b/src/nodes/from_str.rs @@ -9,6 +9,7 @@ impl Node { Ok(match s { "c" => Self::Number(Float::with_val(PREC, 299_792_458)), "A" => Self::Number(Float::with_val(PREC, 6.02214076e23)), + "pi" => Self::Number(Float::with_val(PREC, 3.1415926536)), _ => Self::Function(s.parse()?), }) } diff --git a/src/nodes/tests.rs b/src/nodes/tests.rs index 59995fe..81c2ab9 100644 --- a/src/nodes/tests.rs +++ b/src/nodes/tests.rs @@ -22,6 +22,10 @@ fn constants() { Nodes::from_str("A").unwrap().evaluate().to_f64(), 6.02214076e23 ); + assert_eq!( + Nodes::from_str("pi").unwrap().evaluate().to_f64(), + 3.1415926536 + ); } #[test]