Improved unit printing

This commit is contained in:
2023-04-09 08:39:22 -07:00
parent 2fb25fb742
commit e9645208d9
6 changed files with 46 additions and 9 deletions

View File

@ -24,6 +24,7 @@ pub trait ScalarBase:
// Utility
fn fract(&self) -> Option<Self>;
fn is_zero(&self) -> bool;
fn is_one(&self) -> bool;
fn is_negative(&self) -> bool;
fn is_positive(&self) -> bool;
@ -163,6 +164,13 @@ impl Scalar {
}
}
pub fn is_one(&self) -> bool {
match self {
Scalar::Rational{v} => v.is_one(),
Scalar::Float{v} => v.is_one(),
}
}
pub fn is_negative(&self) -> bool {
match self {
Scalar::Rational{v} => v.is_negative(),