title: Fast bitwise operations on a long
body: <p>I know I can write the following method to calculate the set bit indexes of a long :</p>
  
  <pre><code>private static List&lt;Integer&gt; bitPositions(long number) {
      final List&lt;Integer&gt; positions = new ArrayList&lt;&gt;();
      int position = 1;
      while (number != 0) {
          if ((number &amp; 1L) != 0) {
              positions.add(position);
          }
          position++;
          number = number &gt;&gt;&gt; 1;
      }
      return positions;
  }
  </code></pre>
  
  <p>My question is : <strong>Is there a faster method to do this</strong> ?</p>