Merge pull request #933 from pmoura/add_epsilon_arithmetic_constant

Add epsilon/0 arithmetic constant
This commit is contained in:
Mark Thom
2021-05-08 15:08:13 -06:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -290,6 +290,12 @@ impl<'a> ArithmeticEvaluator<'a> {
f64::consts::PI, f64::consts::PI,
)))) ))))
} }
&Constant::Atom(ref name, _) if name.as_str() == "epsilon" => {
self.interm
.push(ArithmeticTerm::Number(Number::Float(OrderedFloat(
f64::EPSILON,
))))
}
_ => return Err(ArithmeticError::NonEvaluableFunctor(c.clone(), 0)), _ => return Err(ArithmeticError::NonEvaluableFunctor(c.clone(), 0)),
} }

View File

@@ -227,6 +227,9 @@ impl MachineState {
&HeapCellValue::Atom(ref name, _) if name.as_str() == "e" => { &HeapCellValue::Atom(ref name, _) if name.as_str() == "e" => {
interms.push(Number::Float(OrderedFloat(f64::consts::E))) interms.push(Number::Float(OrderedFloat(f64::consts::E)))
} }
&HeapCellValue::Atom(ref name, _) if name.as_str() == "epsilon" => {
interms.push(Number::Float(OrderedFloat(f64::EPSILON)))
}
&HeapCellValue::NamedStr(arity, ref name, _) => { &HeapCellValue::NamedStr(arity, ref name, _) => {
let evaluable_stub = MachineError::functor_stub(name.clone(), arity); let evaluable_stub = MachineError::functor_stub(name.clone(), arity);