Strict printing for powers

pull/2/head
Mark 2023-04-07 09:42:43 -07:00
parent 82b577568c
commit dd9633d822
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 6 additions and 6 deletions

View File

@ -108,8 +108,8 @@ impl Operator {
Operator::Power => { Operator::Power => {
return format!( return format!(
"{}^{}", "{}^{}",
self.add_parens_to_arg(&args[0]), self.add_parens_to_arg_strict(&args[0]),
self.add_parens_to_arg(&args[1]) self.add_parens_to_arg_strict(&args[1])
); );
}, },
@ -146,7 +146,7 @@ impl Operator {
return format!("{} + {}", self.add_parens_to_arg(a), self.add_parens_to_arg(b)); return format!("{} + {}", self.add_parens_to_arg(a), self.add_parens_to_arg(b));
} }
}, },
Operator::Multiply => { Operator::Multiply => {
let a = &args[0]; let a = &args[0];
let mut b = &args[1]; let mut b = &args[1];
@ -344,7 +344,7 @@ impl Operator{
} }
return Ok(Token::Number(sum)); return Ok(Token::Number(sum));
}, },
Operator::Multiply => { Operator::Multiply => {
let mut prod = Quantity::new_rational(1,1); let mut prod = Quantity::new_rational(1,1);
for i in args.iter() { for i in args.iter() {
@ -357,7 +357,7 @@ impl Operator{
} }
return Ok(Token::Number(prod)); return Ok(Token::Number(prod));
}, },
Operator::ModuloLong Operator::ModuloLong
| Operator::Modulo => { | Operator::Modulo => {
if args.len() != 2 {panic!()}; if args.len() != 2 {panic!()};
@ -366,7 +366,7 @@ impl Operator{
if let Token::Number(va) = a { if let Token::Number(va) = a {
if let Token::Number(vb) = b { if let Token::Number(vb) = b {
if vb <= Quantity::new_rational(1,1) { return Err(()); } if vb <= Quantity::new_rational(1,1) { return Err(()); }
if va.fract() != Quantity::new_rational(0,1) { return Err(()); } if va.fract() != Quantity::new_rational(0,1) { return Err(()); }
if vb.fract() != Quantity::new_rational(0,1) { return Err(()); } if vb.fract() != Quantity::new_rational(0,1) { return Err(()); }