title: How can I convert (binary) integer into array?
body: <p>I have the following form select field in my HTML code - </p>
  
  <pre><code>&lt;select multiple class="form-control" name="uploadSites[]" id="uploadSitesDecoded"&gt;
      &lt;option value="1"&gt;Site 1&lt;/option&gt;
      &lt;option value="2"&gt;Site 2&lt;/option&gt;
      &lt;option value="4"&gt;Site 3&lt;/option&gt;
      &lt;option value="8"&gt;Site 4&lt;/option&gt;
      &lt;option value="16"&gt;Site 5&lt;/option&gt;
      &lt;option value="32"&gt;Site 6&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Now I'd like to pre-select the options based on an integer value, e.g. the value 15 should pre-select Site 1, 2, 3 and 4. </p>
  
  <p>As far as I know this can be done using the jQuery trigger method - </p>
  
  <pre><code>$('#uploadSitesDecoded').val([1,2,4,8]).trigger('change');
  </code></pre>
  
  <p>So what I'm trying to do is to convert 15 to a string or array as 1,2,4,8 (unless someone knows an easier way).</p>