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.
This commit is contained in:
electria 2026-07-16 00:36:36 -07:00
commit fc06e1e981
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
2 changed files with 5 additions and 0 deletions

View file

@ -9,6 +9,7 @@ impl Node {
Ok(match s { Ok(match s {
"c" => Self::Number(Float::with_val(PREC, 299_792_458)), "c" => Self::Number(Float::with_val(PREC, 299_792_458)),
"A" => Self::Number(Float::with_val(PREC, 6.02214076e23)), "A" => Self::Number(Float::with_val(PREC, 6.02214076e23)),
"pi" => Self::Number(Float::with_val(PREC, 3.1415926536)),
_ => Self::Function(s.parse()?), _ => Self::Function(s.parse()?),
}) })
} }

View file

@ -22,6 +22,10 @@ fn constants() {
Nodes::from_str("A").unwrap().evaluate().to_f64(), Nodes::from_str("A").unwrap().evaluate().to_f64(),
6.02214076e23 6.02214076e23
); );
assert_eq!(
Nodes::from_str("pi").unwrap().evaluate().to_f64(),
3.1415926536
);
} }
#[test] #[test]