RE:Re: Rank of && and ||

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Sun Mar 05 2000 - 15:02:41 MET


Hello,

I'd like to comment about the &&, || precedence problem. 
This is a cint problem. Cint does not behave like standard.
There is a complication with && || operators which makes it
difficult to fix. Please use () to avoid confusion for the
time being.

Thank you
Masaharu Goto


>
>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:21 MET