12-12-2022, 09:38 AM
(This post was last modified: 12-12-2022, 09:48 AM by NasaCow.
Edit Reason: Is an artist ever really done?
)
(12-11-2022, 02:51 PM)SMcNeill Wrote: https://staging.qb64phoenix.com/showthread.php?tid=1187 <-- Read this for EQV, and then see if you have any questions.
(12-11-2022, 08:21 PM)SMcNeill Wrote:(12-11-2022, 05:39 PM)TempodiBasic Wrote: wow I googled and found the order of execution of the logical operator in QB
from first to last: NOT AND OR XOR EQV IMP
is this the same order of execution made by QB64pe? I think so, but I wait for developers response.
If you want our order of operations, check inside the code for my math evaluation routine. Math Evaluator (qb64phoenix.com)
For our logical operators, they're last in the list and in this order:
Code: (Select All)'Logical Operations PL 80+
i = i + 1: ReDim _Preserve OName(i): OName(i) = "NOT"
ReDim _Preserve PL(i): PL(i) = 80
i = i + 1: ReDim _Preserve OName(i): OName(i) = "AND"
ReDim _Preserve PL(i): PL(i) = 90
i = i + 1: ReDim _Preserve OName(i): OName(i) = "OR"
ReDim _Preserve PL(i): PL(i) = 100
i = i + 1: ReDim _Preserve OName(i): OName(i) = "XOR"
ReDim _Preserve PL(i): PL(i) = 110
i = i + 1: ReDim _Preserve OName(i): OName(i) = "EQV"
ReDim _Preserve PL(i): PL(i) = 120
i = i + 1: ReDim _Preserve OName(i): OName(i) = "IMP"
ReDim _Preserve PL(i): PL(i) = 130
So all AND statements will be resolved before OR statements, much like how multiplication is resolved before addition or subtraction. (PL is Priority Level. Lower goes first over higher.)
One note though: NOT is an awfully strange beast. It's of the highest priority and yet also of the lowest priority. Unique handling is required when parsing it, as it doesn't truly fit into our order of operations like you'd expect. It's rather confusing to understand fully, and not worth derailing this topic here with it, but if you're truly interested in how it's parsed, start another topic on NOT somewhere, and I'll refresh my memory and try to explain the PITA that it is for you. If you're just mildly interested, and don't want a headache from it, just keep in mind, "NOT is a special beast when parsing and order of operations. Ask more about it if it ever comes up that I need to implement proper evaluation order myself with it."
Exactly what I was hoping to see. Now I know why, AND before OR before EQV. You guys went on a tear after I went to sleep (GMT +8). Thanks again everyone
Edit: A quick thought, might want to make a note that the table in the wiki is in the order of Boolean operations as well as what was discussed here, would helped me without showing off the EQV in a program. Hell, might make a good wiki page altogether, order of operations. Love learning something new every day!