# & and && ?

To C++ Experts,
How do I calculate these :
------------------------------
int z = x & y ;
int w = x && y ;
------------------------------
if x and y are both integers, how do I calculate z and w ?
thanks.
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
meow00:

>   How do I calculate these :
>    int z = x & y ;
>    int w = x && y ;
>   if x and y are both integers, how do I calculate z and w ?

"&" is a bit-wise operator.  Here is a description of how it works:
http://www.codeproject.com/cpp/bitbashing.asp

"&&" is a logical "and" operator.  Basically it works like this:

A && B = X

If A is true (not 0) AND B is true, then X will be True (1).
If either A or B is not true (equal to 0), then X will be False.

Hope that helps,
Dex*
0

Experts Exchange Solution brought to you by