]> Repositorios git - scryer-prolog.git/commitdiff
Add epsilon/0 arithmetic constant
authorPaulo Moura <>
Sat, 8 May 2021 20:23:54 +0000 (21:23 +0100)
committerPaulo Moura <>
Sat, 8 May 2021 20:23:54 +0000 (21:23 +0100)
src/arithmetic.rs
src/machine/arithmetic_ops.rs

index 87e72d45f1f2cba895003285f89a48c3f92cd91f..f5a3beeb2f956db86e540cd3438693d675b8b751 100644 (file)
@@ -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)),
         }
 
index 9ce4eac05cebc0e0a1b080f6b44aa4f12d528592..dc06fd5a901ae7f4782de30dec8a884050621e7b 100644 (file)
@@ -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);