• Forum
  • Lounge
  • The Algorithm - The Amazing Story of the

 
The Algorithm - The Amazing Story of the FISR (Fast Integer Square Root)

If you prefer text, this article has a neat derivation and everything:
http://h14s.p5r.org/2012/09/0x5f3759df.html

The author claims that the function did not originate in the Quake codebase.
Last edited on
I learned long time ago there is no such thing as "fast sqrt", I tried out 15+ existing algorithms and run perfomance testing, but none gave me the speed and precision of std::sqrt

Few examples here:
http://www.azillionmonkeys.com/qed/sqroot.html
It's possible that Carmack's implementation was faster than hardware implementations of the day, but that modern FPUs have gotten so much better that it's not even worth it to try to replace one or two FPU instructions with multiple integer/control instructions.
Mine was not the original post. The first one linked to some video.

I learned long time ago there is no such thing as "fast sqrt", I tried out 15+ existing algorithms and run perfomance testing, but none gave me the speed and precision of std::sqrt

Not only does the Quake 3 implementation contain a textbook example of undefined behavior, it's also a relic.
On x86, the only thing that stops std::sqrt from being as simple as
sqrtsd xmm0, xmm0
is that it must set errno in certain cases.

Fortunately there are ways to turn off strict compliance (to IEC559 and the C++ standard) via compiler flags.
https://godbolt.org/z/7jKsaTaMc
Last edited on
mbozzi wrote:
Mine was not the original post. The first one linked to some video.

It wasn't mine either but the videos were the story of this 'strange' algorithm found in the Quake III Arena source code and how it works. There is some interesting bits of back ground information on how numbers are represented in computers and finishes with a comparison of it against modern methods. Just remember this is a story not a tutorial.

I'm not sure why the original was deleted but here are the links anyway:
https://www.youtube.com/watch?v=uCv5VRf8op0
https://www.youtube.com/watch?v=Fm0vygzVXeE
Last edited on
The 0x5f3759df - ( i >> 1 ) step is pretty crazy. I don't know what they were on when whoever came up with it.
If you follow the mathematical explanation, it is most logical, cap'n.
I'm not sure why the original was deleted

I can't answer that, but I did notice the OP deleted their account before they got the boot.
The only way a post can be deleted after it has been replied to is if someone reports it, so it was very probably spam.
Well, twicker could delete it manually, but I imagine it would have to be something pretty objectionable for that to happen. I'm not sure that has ever happened.

PS: By the way, is it just me, or is the site running much better than last year (or maybe earlier than that)? I no longer get those 10+ second hangs I used to get.
Last edited on
I didn't say the user in question wasn't reported, nor did I say it was spam. I simply stated I don't know how they were given the boot. I know it wasn't me.

I discovered in the past that deleting a closed account user is (relatively) easy, no matter what their post count is. The original post requires a two-step report process, all followup posts a single reporting.

Now I only report obvious spammers.

Even spammers/trolls can be resistant to reporting if they have been around for a while with old-ish posts, a low post count is an on-again-off-again no guarantee.

PS: By the way, is it just me, or is the site running much better than last year (or maybe earlier than that)? I no longer get those 10+ second hangs I used to get.

I hadn't really noticed, but now that you mention it, yeah. The site does seem to be less twitchy now.
I discovered in the past that deleting a closed account user is (relatively) easy, no matter what their post count is.
Wow, never knew that.
I kinda wish I didn't know how easy it is, but I do.

I don't bother any more, but clearly someone else is taking the time to clean up.

Oh, icky-poo! More non-programming conversation! How RUDE!
Topic archived. No new replies allowed.