mirror of
https://github.com/rm-dr/daisy
synced 2025-07-05 10:09:33 -07:00
Fixed minus printing
This commit is contained in:
@ -3,5 +3,5 @@ mod rationalq;
|
||||
pub mod quantity;
|
||||
pub use crate::quantity::quantity::Quantity;
|
||||
|
||||
const FLOAT_PRECISION: u32 = 2048;
|
||||
const FLOAT_PRECISION: u32 = 1024;
|
||||
const PRINT_LEN: usize = 5; // How many significant digits we will show in output
|
@ -246,6 +246,20 @@ impl Quantity {
|
||||
Quantity::Rational { .. } => {panic!()}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_negative(&self) -> bool {
|
||||
match self {
|
||||
Quantity::Float { v } => {v.is_sign_negative() && v.is_normal()},
|
||||
Quantity::Rational { v } => {v.is_negative()}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_positive(&self) -> bool {
|
||||
match self {
|
||||
Quantity::Float { v } => {v.is_sign_positive() && v.is_normal()},
|
||||
Quantity::Rational { v } => {v.is_positive()}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Neg for Quantity where {
|
||||
|
@ -86,6 +86,9 @@ impl RationalQ {
|
||||
}
|
||||
|
||||
|
||||
pub fn is_negative(&self) -> bool { self.val.clone().signum() == -1 }
|
||||
pub fn is_positive(&self) -> bool { self.val.clone().signum() == 1 }
|
||||
|
||||
pub fn exp(&self) -> Quantity {float!(self.to_float().exp())}
|
||||
|
||||
pub fn abs(&self) -> Quantity {rational!(self.val.clone().abs())}
|
||||
|
Reference in New Issue
Block a user