Cleanup, added to_string_outer

This commit is contained in:
2023-04-10 11:10:27 -07:00
parent a38293c247
commit ae05ebb5ff
5 changed files with 33 additions and 10 deletions

View File

@ -36,6 +36,16 @@ impl ToString for Quantity {
}
impl Quantity {
pub fn to_string_outer(&self) -> String {
let n = self.v.to_string();
if self.unitless() { return n; }
let u = self.u.to_string();
return format!("{n} {u}");
}
pub fn new_float(f: f64) -> Option<Quantity> {
let v = Scalar::new_float(f);
if v.is_none() { return None; }