QB64 Phoenix Edition
NOT OOO - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: NOT OOO (/showthread.php?tid=1270)



NOT OOO - SMcNeill - 12-13-2022

From the thread here, I had a couple of people message me about NOT and why I mentioned it was an oddball in the Order Of Operations (OOO).  Let me see if I can explain this simply, without confounding the issue..

Exponents are one of the first things we solve in our OOO.  Right?

And NOT is down near the end of our OOO.  Right?

So following those rules, write a program to parse and solve: 1 ^ NOT 2 ^ 3 AND 4

???   <-- Now how the heck DOES it calculate that???

The odd secret is NOT is both calculated FIRST, and near the LAST of our OOO.

Here's the trick I learned:  Put a beginning parentheses BEFORE your NOT, and the ending parentheses before any binary operators like AND, OR, EQV...

1 ^ NOT 2 ^ 3 AND 4 gets solved as:  1 ^ (NOT 2 ^ 3) AND 4

1 ^ (NOT 2 ^ 3) AND 4 makes sense to us.  Do the parentheses FIRST, even if NOT might be evaluated down low on the OOO.

You can't just say, "Solve it last," as sometimes, such as in this case, you have to solve it first before you can do the other operations.  1 raised to the WHAT power?   The (NOT 2 ^ 3)rd power!

Put a beginning parentheses BEFORE your NOT, and the ending parentheses before any binary operators like AND, OR, EQV.  <-- That's the rule for parsing and solving NOT properly.


RE: NOT OOO - Pete - 12-13-2022

Vince will be sending you flowers any second now...

Pete