Skip to content

Comment on Quake's Fast Inverse Square Rootparent

Comments

It's an approximation, and thus does not comply with the IEEE floating-point standard. That is, numerical results of the operations should be correct up to the precision of the floating-point number. There's lots of optimizations possible with floating-point math if speed/energy-efficiency is prioritized over accuracy or standard compliance.

All of the IEEE floating point standard is an approximation :).

It's a cool hack but very mid-90s centric and not that all applicable today. In modern pipelined processors with segregated register files the cost of moving a piece of data from floating point registers to integer registers and back again -- along with pretty much all modern instruction sets (SSE, AltiVec, NEON) coming with instructions that give you a means to calculate a reciprocal square root (either directly or with an estimate + refine) -- means that such a trick is no longer practical.

I think we should be thinking again the floating-point implementations on CPUs. I guess hacks like this directly on hardware would double the battery life on mobile devices. IEEE level accuracy is rarely needed either in number precision or computation accuracy. I guess fast IEEE square root isn't either space or energy efficient on silicon.

I disagree -- the amount of silicon dedicated to this type of operation is miniscule compared to the caches on modern processors. Removing hardware floating point reciprocal square root isn't going to have any noticeable effect on power consumption.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.