Bitwise '&' operator

bitwise-operators, c

Solution

5 is 101.

4 is 100.

`5 & 4` is not 0:

101 
100 &
↓↓↓
100

Problem solved ✓

Clarification:

In C, every non-zero value satisfies the `if` condition. Meaning, if you write:

if (-5) {
  if (100) {
     // reachable code
  }
}

Whereas:

if (0) {
  destroyTheWorld(); // we are safe
}

Problem

I am lacking some basic understanding in bitwise '&' operator. ``` 5 = 101 4 = 100 ``` So why the output of the below `if` condition is true cause and of bits `101 & 100` should be false: ``` #include <stdio.h> main() { if(5&4) printf("Yes\n"); } ```

Original source