Solved

# & and && ?

Posted on 2003-10-27
168 Views
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.
0
Question by:meow00
1 Comment

LVL 19

Accepted Solution

Dexstar earned 40 total points
ID: 9629858
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

## Featured Post

This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.