Operator precedence of % vs ^

alexperl shared this idea 11 months ago
Declined

When typing


3*10^15 %


, I would expect to get as answer one hundredth of my input, ergo


3*10^13


But this is not what happens. Instead, GeoGebra seems to bind the "%" sign directly to the exponent "15", effectively calculating "3*10^(15%)", giving


4.237612633868


This is not at all what I would expect from above input.


This behaviour also doesn't make sense from a mathematical standpoint, where "%" means "divide by 100", so consequently it should have the same operator precendence as a division or multiplication, but instead it gets evaluated even prior to the exponentiation "^".


Suggestion: Change order precedence of "%" to the level of "*" and "/"!

Comments (4)

photo
1

Strangely enough, this faulty behaviour can't even be overruled by adding parentheses!


92c0ce9170ace0372e5796c75495244d

photo
1

Actually, this whole "%" thing seems deeply broken. I also get an error when trying


3*10^(-7) %


Although it is completely obvious that the correct output should be "3*10^(-9)"!

photo
photo
1

Actually, the easiest solution would be to simply replace each occurence of "%" by "/100" or "*0.01" before evaluating the whole string. All problems solved, no new problems introduced.

photo
1

Sorry, we won't change that

© 2022 International GeoGebra Institute