title: Loop and return all bitwise values in Long
body: <p>To set bits, you use the OR operator. You can then use the AND operator to see which bits have been set:</p>
  <pre><code>long values = 0;
  
  // Set bits
  values |= (1L &lt;&lt; 10);
  values |= (1L &lt;&lt; 45);
  values |= (1L &lt;&lt; 5600);
  
  // Check if values are set
  System.out.println(hasValue(values, 45));   // Returns true
  System.out.println(hasValue(values, 55));   // Returns false
  System.out.println(hasValue(values, 5600)); // Returns true
  
  public static boolean hasValue(long data, int value)
  {
      return (((data &gt;&gt; value) &amp; 1L) &gt; 0);
  }
  </code></pre>
  <p>Is it possible to loop through <code>values</code> and return each of the values originally set with the OR operator? The result printing:</p>
  <pre><code>Found value: 10
  Found value: 45
  Found value: 5600
  </code></pre>
  <p><strong>Edit</strong>: Altered example to include larger numbers.</p>