From 9e0c6a732bb2e26e5133bc0e612ac98ebb5d2416 Mon Sep 17 00:00:00 2001 From: bakk Date: Sun, 23 May 2021 16:08:25 +0200 Subject: [PATCH] abs() the imaginary value on to_string(), since the sign is already there --- kalk/src/kalk_num/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kalk/src/kalk_num/mod.rs b/kalk/src/kalk_num/mod.rs index 502f4c5..91f99b7 100644 --- a/kalk/src/kalk_num/mod.rs +++ b/kalk/src/kalk_num/mod.rs @@ -137,7 +137,7 @@ impl KalkNum { let as_str = trim_number_string(&self.to_f64().to_string()); if self.has_imaginary() { - let imaginary_as_str = trim_number_string(&self.imaginary_to_f64().to_string()); + let imaginary_as_str = trim_number_string(&self.imaginary_to_f64().abs().to_string()); let sign = if self.imaginary_value < 0f64 { "-" } else { @@ -396,7 +396,7 @@ impl KalkNum { Some(output) } - pub fn estimate_one_value(&self, complex_number_type: ComplexNumberType) -> Option { + fn estimate_one_value(&self, complex_number_type: ComplexNumberType) -> Option { let (value, value_string) = match complex_number_type { ComplexNumberType::Real => (&self.value, self.to_string()), ComplexNumberType::Imaginary => (&self.imaginary_value, self.to_string_imaginary(true)),