probablykasper / cpc

Text calculator with support for units and conversion
https://crates.io/crates/cpc
MIT License
121 stars 14 forks source link

Negative exponents are calculated incorrectly without parenthesis #37

Closed Delta-official closed 10 months ago

Delta-official commented 10 months ago

As of 1.9.2, cpc incorrectly calculates the sign of negative exponents without parenthesis

Expression Result Expected
-3^2 9 -9
(-3)^2 9 9
probablykasper commented 10 months ago

Hmm it's a bit tricky. - may or may not take precedence over ^ depending on it's position:

-3^2 == -(3^4)
3^-2 == 3^(-2)
probablykasper commented 10 months ago

Nevermind, not that tricky. Released the fix in v1.9.3