Board Thread:Questions and Answers/@comment-19840316-20140717223735/@comment-5334617-20140718011846

The page List of Operators tells you that  has higher precedence than. So, the expression  is interpreted the same as. The same page tells you that  is left-associative, so the expression is the same as.

The central operator in  is , which will always give the boolean value   or  , which in SmileBasic V2 really means the numerical value 1 or 0. will always have the numerical result of 0 or 512. If this numerical result is used directly as a boolean value, 0 will have the logical sense of FALSE, and 512 (because it is nonzero) will have the logical sense of TRUE. However,, in this instance, is not used as a boolean logic value, it is used as an operand to the (numerical, bitwise)   operator. The first operand to this  is either 0 or 512, and the second operand is either 0 or 1. Bitwise 0 AND 0 is 0; 0 AND 1 is 0; 512 AND 0 is 0; 512 AND 1 is 0. All combinations will give 0 (FALSE).

If you stick with the boolean values TRUE and FALSE, the numerical bitwise AND will always be the same as the boolean logical AND. The problem is that  is not strictly a boolean value, even though when put in the context where the system expects a boolean value (between an   and a  ), it will be interpreted as you would want it to be.

What you want is for  to be a proper boolean value. One way to do this is to use  instead. Alternately, you could do. (Also, instead of, you can use  .)