For example:
What happens here?
if(63 & 1)
{
......
}
Edited by bigdilliams, 18 November 2012 - 08:10 AM.
Posted 18 November 2012 - 08:09 AM
Posted 18 November 2012 - 08:17 AM
A bitwise AND takes two binary representations of equal length and performs the logical AND operation on each pair of corresponding bits. The result in each position is 1 if the first bit is 1 and the second bit is 1; otherwise, the result is 0. In this, we perform the multiplication of two bits; i.e., 1 × 0 = 0 and 1 × 1 = 1
Edited by nife87, 18 November 2012 - 08:19 AM.
Posted 18 November 2012 - 08:20 AM
Yes, but I made a small programm wich results in:
int Zahl = (54 & 63); std::cout << Zahl;63= 111111
54= 110110
so Zahl = 54
What is the sense behind that?
Edited by nife87, 18 November 2012 - 08:21 AM.
Posted 18 November 2012 - 08:30 AM
| P AND (&) Q | ||
|---|---|---|
| P | Q | P AND Q |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Edited by Radikalizm, 18 November 2012 - 08:32 AM.
Posted 18 November 2012 - 08:43 AM
When will the if-loop start?
Is the condition everytime true, and is it possible to be false with an other number?
Posted 18 November 2012 - 08:44 AM
What if I make this:
if(63 & 1) { ... }
When will the if-loop start?
Is the condition everytime true, and is it possible to be false with an other number?
Edited by kuramayoko10, 18 November 2012 - 08:46 AM.
Posted 18 November 2012 - 02:29 PM
What if I make this:
if(63 & 1) { ... }
When will the if-loop start?
Is the condition everytime true, and is it possible to be false with an other number?
if(63 & 1)is equal to
if(1)