From: Paulo Moura <> Date: Sat, 8 May 2021 20:23:54 +0000 (+0100) Subject: Add epsilon/0 arithmetic constant X-Git-Tag: v0.9.0~84^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=3f4bbe9b9e02d0e7f424d6fabfe7e40ea7c9b205;p=scryer-prolog.git Add epsilon/0 arithmetic constant --- diff --git a/src/arithmetic.rs b/src/arithmetic.rs index 87e72d45..f5a3beeb 100644 --- a/src/arithmetic.rs +++ b/src/arithmetic.rs @@ -290,6 +290,12 @@ impl<'a> ArithmeticEvaluator<'a> { 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)), } diff --git a/src/machine/arithmetic_ops.rs b/src/machine/arithmetic_ops.rs index 9ce4eac0..dc06fd5a 100644 --- a/src/machine/arithmetic_ops.rs +++ b/src/machine/arithmetic_ops.rs @@ -227,6 +227,9 @@ impl MachineState { &HeapCellValue::Atom(ref name, _) if name.as_str() == "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, _) => { let evaluable_stub = MachineError::functor_stub(name.clone(), arity);