1. ## bitwise IF statement

Hello!

I have a simple question here:
How does an IF statement react on bitwise commands like this:
a = 0x07;
b = 0x02;

if(a&b)
DoSomething();

Is the IF statement TRUE or FALSE?

Tnx
/D

2. this statement would be true:
since 0x7 = 0111 bin
and 0x2 = 0010 bin

-> the result of the & operation is 0x2
and this is not 0, so its True

3. I'd say it returns true.

0x07 in binary is 111 and 0x02 is 010, so when it does the math
Code:
```  111
& 010
----------
010```
which gives 2 as a result anyway.

EDIT: Damn you IceBall, you beat me!

4. Originally Posted by DeeAitch
How does an IF statement react on bitwise commands like this:
Code:
```   a = 0x07;
b = 0x02;

if (a & b)
DoSomething();```
Is the IF statement TRUE or FALSE?
There is no 'IF' in C. Maybe you meant 'if'.

There is no 'command' in C, but statements, operators, expressions, functions...

A C expression returns 0 or 1, not TRUE/FALSE.

Simple question of boolean logic. What is the AND truth table, what is the result of 0x07 AND 0x02 ?
Code:
```      a = 0000 0111
b = 0000 0010
a AND b = ???? ????```