Talks to Watch

Fast Inverse Square Root — A Quake III Algorithm

6M views · Nov 28, 2020 · 20:08 · 3 HN recommenders · 4 mentions · discussed 2021–2022

A walkthrough of the Quake III fast inverse square root, explaining where the constant 0x5f3759df comes from. It covers IEEE 754 floats, the bit hack that approximates a logarithm, and a Newton's method refinement.

Why Hacker News points people here: HN recommends it as an approachable explanation that makes the famous algorithm finally make sense.

“This video is approachable and explains it pretty well”HN comment, 2021

What Hacker News said 4

Strongly recommendsgreyfoxJul 2021

“Here's the very fun video if anyone wants to take a look”

More interesting video about the famous Quake code

Full comment

Very interesting that this was posted as I literally JUST watched an even MORE interesting youtube upload about this very bit of code just last weekend. Here's the very fun video if anyone wants to take a look: this video

in “Copilot regurgitating Quake code, including sweary comments” · view on HN
Recommendscolejohnson66Aug 2021

“Once that coincidence(?) was explained, Q_rsqrt finally made sense.”

Explains float bits as logarithm, making Q_rsqrt make sense

Full comment

> The bits of a float as an integer literal are proportional to its log2 value (plus a constant), … I watched a video[0] a while back about that. Once that coincidence(?) was explained, Q_rsqrt finally made sense. [0]: this video (~20 minutes)

in “One does not simply calculate the absolute value” · view on HN
RecommendsinfogulchSep 2021

“This video is approachable and explains it pretty well”

Approachable explanation of why fast inverse square root works

Full comment

Apparently the bit pattern of a float interpreted as an int is sorta-kinda it's own logarithm, which is why the famous fast inverse square root from quake 3 works: log(x^-½) = -½log(x) =~ -log(x) >> 1. This video is approachable and explains it pretty well: this video

Cites itbitwidgetAug 2022

“I've heard good things about the Fast Inverse Square Root Calculation algorithm”

Famous algorithm cited as great code

Full comment

print("Hello World") /s But I've heard good things about the Fast Inverse Square Root Calculation algorithm in the Doom 3 source code. this video

in “Ask HN: What's a small example of some of the best code ever written?” · view on HN