From 7cb9dbf2e08ebb669facd46baadfd5eca987afae Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 3 Aug 2023 07:47:07 -0700 Subject: [PATCH] Hack for large exponents --- src/parser/expression/operator.rs | 4 ++-- src/quantity/unit/unit.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parser/expression/operator.rs b/src/parser/expression/operator.rs index 1486dd9..9794b1d 100644 --- a/src/parser/expression/operator.rs +++ b/src/parser/expression/operator.rs @@ -209,11 +209,11 @@ impl Operator { let q = &args[1]; - if q.is_unitless_integer() { + if q.is_unitless_integer() && !q.to_string().contains("e") { // Write integer powers as a superscript let mut b = String::new(); for c in q.to_string().chars() { - b.push( match c { + b.push(match c { '-' => '⁻', '0' => '⁰', '1' => '¹', diff --git a/src/quantity/unit/unit.rs b/src/quantity/unit/unit.rs index b068504..40e35c4 100644 --- a/src/quantity/unit/unit.rs +++ b/src/quantity/unit/unit.rs @@ -37,7 +37,7 @@ impl ToString for Unit { if *p == Scalar::new_rational(1f64).unwrap() { t.push_str(&format!("{c}·")); - } else if p.is_int() { + } else if p.is_int() && !p.to_string().contains("e"){ t.push_str(&c); for c in p.to_string().chars() { t.push( match c { @@ -74,7 +74,7 @@ impl ToString for Unit { bottom_count += 1; if t.len() != 0 && *p == Scalar::new_rational(-1f64).unwrap() { b.push_str(&format!("{c}·")); - } else if p.is_int() { + } else if p.is_int() && !p.to_string().contains("e") { b.push_str(&c); for c in p.to_string().chars() { if c == '-' && t.len() != 0 { continue; }