title: How can I get/set individual bits in a float?
body: <p>I have to admit in all my work with Java, I've never come across the need for a Java union (like the C union, not the SQL one) and I cannot find an answer here on SO. Admittedly, most of my work in Java has been at higher abstractions than bit-fiddling.</p>
  
  <p>I have a integer which I'm setting individual bits for and I want to print out the equivalent IEEE754 single-precision float.</p>
  
  <p>In C, I'd do something like:</p>
  
  <pre><code>union {
      int i;
      float f;
  } x;
  x.i = 0x27;
  printf ("%f\n", x.f);
  </code></pre>
  
  <p>How do I do a similar thing in Java? Is it even possible to treat the same memory as two different data types in Java?</p>
  
  <p>I did search on both SO and elsewhere for "java union" but it swamped me with SQL stuff - I couldn't find a way to do this.</p>