mirror of
https://github.com/rm-dr/daisy
synced 2025-07-05 10:09:33 -07:00
Minor changes
This commit is contained in:
@ -102,11 +102,17 @@ impl Quantity {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_float_from_string(s: &str) -> Quantity {
|
||||
pub fn new_float_from_string(s: &str) -> Option<Quantity> {
|
||||
let v = Float::parse(s);
|
||||
return Quantity::Float {
|
||||
v: Float::with_val(FLOAT_PRECISION, v.unwrap())
|
||||
}
|
||||
|
||||
let v = match v {
|
||||
Ok(x) => x,
|
||||
Err(_) => return None
|
||||
};
|
||||
|
||||
return Some(Quantity::Float {
|
||||
v: Float::with_val(FLOAT_PRECISION, v)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -189,6 +195,7 @@ impl Quantity {
|
||||
}
|
||||
|
||||
quick_quant_fn!(fract);
|
||||
quick_quant_fn!(exp);
|
||||
|
||||
quick_quant_fn!(abs);
|
||||
quick_quant_fn!(floor);
|
||||
|
@ -86,6 +86,8 @@ impl RationalQ {
|
||||
}
|
||||
|
||||
|
||||
pub fn exp(&self) -> Quantity {float!(self.to_float().exp())}
|
||||
|
||||
pub fn abs(&self) -> Quantity {rational!(self.val.clone().abs())}
|
||||
pub fn floor(&self) -> Quantity {rational!(self.val.clone().floor())}
|
||||
pub fn ceil(&self) -> Quantity {rational!(self.val.clone().ceil())}
|
||||
|
Reference in New Issue
Block a user