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:
parent
8d26022403
commit
fc06e1e981
2 changed files with 5 additions and 0 deletions
|
|
@ -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()?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue