From e3fdfa3c398f8e8167759fc2f5ea1020f0be39c6 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 2 Aug 2023 09:16:47 -0700 Subject: [PATCH] Fixed unit tobase() conversion --- src/quantity/unit/freeunit.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/quantity/unit/freeunit.rs b/src/quantity/unit/freeunit.rs index 6aea210..d0cc0ce 100644 --- a/src/quantity/unit/freeunit.rs +++ b/src/quantity/unit/freeunit.rs @@ -52,11 +52,11 @@ impl FreeUnit { // Get this unit in terms of base units pub fn to_base(&self) -> Quantity { - let q = self.whole.base_factor(); - let mut q = q.unwrap_or(Quantity::new_rational_from_string("1").unwrap()); + let f = self.to_base_factor(); - // 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.mul_assign_no_convert(f); return q; }