symbol &

Jun 29, 2013 at 11:48am
Hello,

What is the meaning of

 
  (1&3)


Have you some example where it is good to use such a condition?

Thanks
Jun 29, 2013 at 12:40pm
It's a bit wise AND.
Jun 29, 2013 at 2:00pm
For example to determine whether an integer value is odd or even.

1
2
if ( x & 1 ) std::cout << "x is odd\n";
else std::cout << "x is even";
Topic archived. No new replies allowed.