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]