Is there a fast C or C++ standard library function for double precision inverse square root?

Dan picture Dan · Oct 16, 2012 · Viewed 10.5k times · Source

I find myself typing

double foo=1.0/sqrt(...);

a lot, and I've heard that modern processors have built-in inverse square root opcodes.

Is there a C or C++ standard library inverse square root function that

  1. uses double precision floating point?
  2. is as accurate as 1.0/sqrt(...)?
  3. is just as fast or faster than the result of 1.0/sqrt(...)?

Answer

Lightness Races in Orbit picture Lightness Races in Orbit · Oct 16, 2012

No. No, there isn't. Not in C++. Nope.