PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Thomas Bock on October 16, 2019, 09:45:34 AM

Title: incorrect evaluation
Post by: Thomas Bock on October 16, 2019, 09:45:34 AM
In my opinion the following condition should print a star
Code: [Select]
if 1 or 0 and 0 then print "*"It is the same as
Code: [Select]
if 1 or (0 and 0) then print "*"or
Code: [Select]
1+0*0For better understanding we will add the brackets.
PxPlus doesn't print a star. I'm curious, what am I missing?
Title: Re: incorrect evaluation
Post by: James Zukowski on October 16, 2019, 10:06:11 AM
The 'AND' and 'OR' operators have the same precedence level, so they are evaluated left-to-right. In this case, it essentially works out to be:
Code: [Select]
if (1 or 0) and 0 then print "*"