title: Fastest Inverse Square Root on iPhone (Swift, not ObjectC)
body: <p>Refer to
  <a href="https://stackoverflow.com/questions/21038641/fastest-inverse-square-root-on-iphone">Fastest Inverse Square Root on iPhone</a></p>
  
  <p>I need do a "Fastest Inverse Square Root" on iPhone iOS Swift, which is supposed to be faster than <code>1/sqrt(float)</code>.
  How do I do it?</p>
  
  <p>In embedded C programming, it is:</p>
  
  <pre><code>// Fast inverse square-root
  // See: http://en.wikipedia.org/wiki/Fast_inverse_square_root
  func invSqrt(x: Float) -&gt; Float {
      var halfx : Float = 0.5 * x
      var y : Float = x
      long i = *(long*)&amp;y
  
      i = 0x5f3759df - (i&gt;&gt;1)
      y = *(float*)&amp;i
      y = y * (1.5 - (halfx * y * y))
  
      return y
  }
  </code></pre>