title: Convert bitmask back to 9 booleans
body: <p>I have the following code which converts a set of 9 booleans into an int for me, which I'm using for a tilemap sprite array to quickly find the tiles. Just curious, is there a simple way of reversing this?</p>
  
  <p>i.e. if all the bool's are true, the result below would be 511. Is there an easy way to convert that back to assign the booleans all true? Or another example, a is false, the rest are true, result would be 510. How can I convert that back to  a = true and the rest false?</p>
  
  <pre><code>int GetBitmask(bool a, bool b, bool c, bool d, bool e, bool f, bool g, bool h, bool i)
  {
      int r = (a ? 1 &lt;&lt; 0 : 0) | (b ? 1 &lt;&lt; 1 : 0) | (c ? 1 &lt;&lt; 2 : 0) |
              (d ? 1 &lt;&lt; 3 : 0) | (e ? 1 &lt;&lt; 4 : 0) | (f ? 1 &lt;&lt; 5 : 0) |
              (g ? 1 &lt;&lt; 6 : 0) | (h ? 1 &lt;&lt; 7 : 0) | (i ? 1 &lt;&lt; 8 : 0);
      return r;
  }
  </code></pre>