Add epsilon/0 arithmetic constant

This commit is contained in:
Paulo Moura
2021-05-08 21:23:54 +01:00
parent 56eaf883dc
commit 3f4bbe9b9e
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);