3 ms·
Fast Inverse Square Root
- ColinWright 13y agoOK, one very last time. Here are a few previous submissions of this, some of which have comment: https://news.ycombinator.com/item?id=213056 https://news.ycombinator.com/item?id=213056 : Some comments https://news.ycombinator.com/item?id=419166 https://news.ycombinator.com/item?id=419166 : Some comments https://news.ycombinator.com/item?id=573912 https://news.ycombinator.com/item?id=573912 https://news.ycombinator.com/item?id=1599635 https://news.ycombinator.com/item?id=1599635 https://news.ycombinator.com/item?id=2332793 https://news.ycombinator.com/item?id=2332793 : Some comments https://news.ycombinator.com/item?id=3115168 https://news.ycombinator.com/item?id=3115168 : Some comments https://news.ycombinator.com/item?id=3259199 https://news.ycombinator.com/item?id=3259199 https://news.ycombinator.com/item?id=4526609 https://news.ycombinator.com/item?id=4526609 : Some comments https://news.ycombinator.com/item?id=4836589 https://news.ycombinator.com/item?id=4836589 https://news.ycombinator.com/item?id=6106627 https://news.ycombinator.com/item?id=6106627 https://news.ycombinator.com/item?id=7277215 https://news.ycombinator.com/item?id=7277215 https://news.ycombinator.com/item?id=7297582 https://news.ycombinator.com/item?id=7297582
- jtlien1 13y agoA lot of times, the code you are writing does distance comparisons to determine overlap or intersection. But if all you are doing is this, then you can use the square of the distance which is just x^2 + y^2 and you have no need for a square root. Some mathematicians call this "quadrance". Or just do all your work in this metric and reserve the square rooting for when it is absolutely necessary.
- hehaho 13y agoFor a second I was expecting this to be an April Fool's post about a "fast" way to calculate the inverse of the square root function, i.e. x*x :-)