Vincent Delecroix on Tue, 07 Dec 2021 21:07:36 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: logical operators -- documentation |
As far as I understand, your example does not contradict the documentation. n%2==1 || 1<0 && 3<2 || 3>2 should be read (((n%2==1) || 1<0) && 3<2) || 3>2 This is the meaning of "from left to right" as you start evaluating the innermost operation. Vincent Le 07/12/2021 à 13:46, Paul Underwood a écrit :
I am sorry for using "associativity" wrongly. I don't think it is "precedence"; Both || and && have the same "priority" in the documentation. Here is another example: for(n=1,9,if(n%2==1 || 1<0 && 3<2 || 3>2 ,print1(n" "))) 1 2 3 4 5 6 7 8 9 I think the documentation should read "right to left". It currently reads: "Any sequence of logical or and and operations is evaluated from left to right, and aborted as soon as the final truth value is known." I think the upshot is that || does appear to have great precedence than &&. Best Paul