This commit is contained in:
2023-04-11 08:56:39 -07:00
parent 84f2d6e30c
commit 0ca7705122
4 changed files with 419 additions and 394 deletions

View File

@ -1,5 +1,6 @@
use rug::Rational;
use rug::Integer;
use rug::ops::Pow;
use std::ops::{
Add, Sub, Mul, Div,
@ -109,6 +110,10 @@ impl ScalarBase for RationalBase {
Some(RationalBase{val: self.val.clone().fract_floor(Integer::new()).0})
}
fn is_int(&self) -> bool {
self.fract() == RationalBase::from_f64(0f64)
}
fn is_zero(&self) -> bool {self.val == Rational::from((0,1))}
fn is_one(&self) -> bool {self.val == Rational::from((1,1))}
fn is_negative(&self) -> bool { self.val.clone().signum() == -1 }