mirror of https://github.com/rm-dr/daisy
Fixed unit tobase() conversion
parent
e71e02c445
commit
e3fdfa3c39
|
@ -52,11 +52,11 @@ impl FreeUnit {
|
||||||
|
|
||||||
// Get this unit in terms of base units
|
// Get this unit in terms of base units
|
||||||
pub fn to_base(&self) -> Quantity {
|
pub fn to_base(&self) -> Quantity {
|
||||||
let q = self.whole.base_factor();
|
let f = self.to_base_factor();
|
||||||
let mut q = q.unwrap_or(Quantity::new_rational_from_string("1").unwrap());
|
|
||||||
|
|
||||||
// Don't divide by self
|
let mut q = Quantity::new_rational_from_string("1").unwrap();
|
||||||
q.insert_unit(FreeUnit::from_whole_prefix(self.whole, self.prefix), Scalar::new_rational(1f64).unwrap());
|
q.insert_unit(FreeUnit::from_whole_prefix(self.whole, self.prefix), Scalar::new_rational(1f64).unwrap());
|
||||||
|
q.mul_assign_no_convert(f);
|
||||||
|
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue