Hi,
 Reply embedded.

--- In [email protected], "Shyan Lam" <[EMAIL PROTECTED]> wrote:
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
> > Of Pedro Izecksohn
> > Sent: Saturday, May 26, 2007 10:15 PM
> >   If any value not zero is true why "true which expands to the integer
> > constant 1"?
> > 
> >   I wasted a week to find a bug that I wrote like:
> > 
> > if ((x&y)==true) //etc
> 
> '&' is a bitwise-AND operator.  I think what you really meant is
> "logical-AND" (&&).
> 
>     if ((x && y) == true)
> 
> Unless you want 'y' to be evaluated regardless of the result of 'x'.
> 
> 
> >   but I should have written just:
> > 
> > if (x&y) //etc
> 
> It still can be shorten to:
> 
>     if (x && y)

Why can it be shortened?
are you sure x&y == x&&y???

#include <stdio.h>

int main()
{
    int x = 2, y =4;
    printf(" bit AND == %d, logical AND == %d\n", (x & y),(x && y) );
    return 1;
}

Output:  bit AND == 0, logical AND == 1

Am I missing something?

Regards,
-Saurabh

Reply via email to