title: C++ XOR swap on float values
body: <p>Is it possible to use XOR swapping algorithm with float values in c++? </p>
  
  <p>However wikipedia says that: </p>
  
  <blockquote>
    <p>XOR bitwise operation to swap values of distinct variables having the same data type</p>
  </blockquote>
  
  <p>but I am bit confused. With this code:</p>
  
  <pre><code>void xorSwap (int* x, int* y) {
     *x ^= *y;
     *y ^= *x;
     *x ^= *y;
  }
  
  int main() {
  
     float a = 255.33333f;
     float b = 0.123023f;
     xorSwap(reinterpret_cast&lt;int*&gt;(&amp;a), reinterpret_cast&lt;int*&gt;(&amp;b));
     std::cout &lt;&lt; a &lt;&lt; ", " &lt;&lt; b &lt;&lt; "\n";
  
     return 0;
  }
  </code></pre>
  
  <p>it seems to work (at least under gcc), but I am concerned if such a practice is allowed if needed?</p>