Merge branch 'dashu' of https://github.com/coasys/scryer-prolog into coasys-dashu

This commit is contained in:
Mark
2023-07-24 11:47:57 -06:00
19 changed files with 279 additions and 149 deletions

View File

@@ -8,7 +8,7 @@ use crate::machine::machine_errors::*;
use crate::machine::machine_indices::*;
use crate::parser::ast::*;
use crate::parser::parser::CompositeOpDesc;
use crate::parser::rug::{Integer, Rational};
use crate::parser::dashu::{Integer, Rational};
use crate::types::*;
use fxhash::FxBuildHasher;
@@ -771,9 +771,9 @@ impl Number {
pub(crate) fn is_positive(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() > 0,
&Number::Integer(ref n) => &**n > &0,
&Number::Integer(ref n) => &**n > &Integer::from(0),
&Number::Float(f) => f.is_sign_positive(),
&Number::Rational(ref r) => &**r > &0,
&Number::Rational(ref r) => &**r > &Rational::from(0),
}
}
@@ -781,9 +781,9 @@ impl Number {
pub(crate) fn is_negative(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() < 0,
&Number::Integer(ref n) => &**n < &0,
&Number::Integer(ref n) => &**n < &Integer::from(0),
&Number::Float(OrderedFloat(f)) => f.is_sign_negative() && OrderedFloat(f) != -0f64,
&Number::Rational(ref r) => &**r < &0,
&Number::Rational(ref r) => &**r < &Rational::from(0),
}
}
@@ -791,9 +791,9 @@ impl Number {
pub(crate) fn is_zero(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() == 0,
&Number::Integer(ref n) => &**n == &0,
&Number::Integer(ref n) => &**n == &Integer::from(0),
&Number::Float(f) => f == OrderedFloat(0f64) || f == OrderedFloat(-0f64),
&Number::Rational(ref r) => &**r == &0,
&Number::Rational(ref r) => &**r == &Rational::from(0),
}
}