|
From: Per W. <pw...@ia...> - 2006-06-29 15:32:32
|
Just note that the OP didn't talk about bit-wise and (&) but bit-wise
xcor, ie an operator that doesn't have a logical equivalent.
(a ^ b) is definitely shorter tahn ((a && !b) || (b && !a))
However, when testing two logical variables with boolean values (i.e.
always the same non-zero value for true) i't enough to write (a != b).
/Per W
On Thu, 29 Jun 2006, Fernando Lichtschein wrote:
> Eric,
>
> By convention, any expression which evaluates to zero is considered false,
> and true if it is different from zero.
>
> The comparison operators such as ==, > or != return 0 if the comparison is
> false and 1 if the comparison is true, so doing a bitwise AND between the
> two results does not make any difference compared to a logical AND (&&) and
> does not add much to clarity.
>
> Regards,
>
> Fernando
>
>
> On 6/29/06, Eric Richards <eri...@cl...> wrote:
> >
> > Hi all
> > This works but at what problems, Can you use bitwise in a if-else or any
> > other program control statement for that matter
> >
> >
> > if (A==1 ^ B==1)
> > {
> >
> > }
> > else
> > {
> >
> > }
> >
> >
> >
> >
> > // from Eric
> >
> >
> > Using Tomcat but need to do more? Need to support web services, security?
> > Get stuff done quickly with pre-integrated technology to make your job
> > easier
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
>
> --
> Fernando Lichtschein
> li...@fi...
>
|