From 3f4bbe9b9e02d0e7f424d6fabfe7e40ea7c9b205 Mon Sep 17 00:00:00 2001 From: Paulo Moura <> Date: Sat, 8 May 2021 21:23:54 +0100 Subject: [PATCH] Add epsilon/0 arithmetic constant --- src/arithmetic.rs | 6 ++++++ src/machine/arithmetic_ops.rs | 3 +++ 2 files changed, 9 insertions(+) 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); -- 2.54.0