Solved

& and && ?

Posted on 2003-10-27
1
168 Views
Last Modified: 2010-04-02
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
Comment
Question by:meow00
1 Comment
 
LVL 19

Accepted Solution

by:
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: SunnyDark
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.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now