title: Check if flag is set in integer variable
body: <p>I am making my own simple drawing engine. I am trying to determine if a variable has been set to a specific value using what I think is called bitwise comparison but I maybe wrong. </p>
  
  <p>I've always been a bit confused about what the following is and how I use it:</p>
  
  <pre><code>int DRAW_REPEAT_X = 70001; // I have a feeling I should make this value binary instead of a unique number, ie, 0
  int DRAW_REPEAT_Y = 70002; // I have a feeling I should make this value binary instead of a unique number, ie, 2
  int drawMethod    = DRAW_REPEAT_X | DRAW_REPEAT_Y; // this means I want to repeat an image on both the x and y axis doesn't it?
  
  // Now I want to check if drawMethod has DRAW_REPEAT_X set: this is where I struggle to know how to check this
  // Is the following correct?
  if (drawMethod &amp;&amp; DRAW_REPEAT_X) {
    // the user wants me to repeat an image along the x axis
  }
  
  // Now I want to check if drawMethod has DRAW_REPEAT_Y set: this is where I struggle to know how to check this
  if (drawMethod &amp;&amp; DRAW_REPEAT_Y) {
    // the user wants me to repeat an image along the x axis
  }
  </code></pre>
  
  <p><strong>Is the following code correctly checking if DRAW_REPEAT_X is set?</strong> It always returns 1 in my anding check.</p>
  
  <p><em>EDIT</em>
  And to check whether both bits are set do I do this?</p>
  
  <pre><code>if (drawMethod &amp; DRAW_REPEAT_X &amp; DRAW_REPEAT_Y) {
     // both set
  }
  
  // OR
  
  if (drawMethod &amp; DRAW_REPEAT_X &amp;&amp; drawMethod &amp; DRAW_REPEAT_Y) {
     // both set
  }
  </code></pre>