title: How to perform a bitwise operation on floating point numbers
body: <p>I tried this:</p>
  
  <pre><code>float a = 1.4123;
  a = a &amp; (1 &lt;&lt; 3);
  </code></pre>
  
  <p>I get a compiler error saying that the operand of <code>&amp;</code> cannot be of type float.</p>
  
  <p>When I do:</p>
  
  <pre><code>float a = 1.4123;
  a = (int)a &amp; (1 &lt;&lt; 3);
  </code></pre>
  
  <p>I get the program running. The only thing is that the bitwise operation is done on the integer representation of the number obtained after rounding off.</p>
  
  <p>The following is also not allowed.</p>
  
  <pre><code>float a = 1.4123;
  a = (void*)a &amp; (1 &lt;&lt; 3);
  </code></pre>
  
  <p>I don't understand why <code>int</code> can be cast to <code>void*</code> but not <code>float</code>.</p>
  
  <p>I am doing this to solve the problem described in Stack Overflow question <em><a href="https://stackoverflow.com/questions/1692418/how-to-solve-linear-equations-using-genetic-algorithm">How to solve linear equations using a genetic algorithm?</a></em>.</p>