Re: Rank of && and ||

From: Paul Nord (PNORD@exodus.valpo.edu)
Date: Wed Mar 01 2000 - 18:06:47 MET


True.

But, standard rules for this logic algebra dictate that the AND should be
evaluated before the OR.  The && should work like * and the || like +.

Standard Precedence of operators:
!
* / mod and
+ - or
== < > <= >= <>

(Operators on the same level have the same precedence.)

Paul

>Masayuki,
>
>It also depends on which order they are evaluated.
>Your expression is F&&F||T which can be
>evaluate (F&&F)||T=T or F&&(F||T)=F.
>
>Jack
>
>Masayuki Etoh wrote:
>
>> Dear ROOTers,
>>
>> I tried the following macro on ROOT-2.23/11 and cint, I got "FALSE".
>> It should be "TRUE", right?
>>
>> Best Regards,
>> Etoh
>>
>> ========================================================================
>> {
>>   int a=1;
>>   if (a==0 && a==0 || a==1) {
>>     printf("TRUE\n");
>>   } else {
>>     printf("FALSE\n");
>>   }
>> }
>> ========================================================================



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET