TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

0x5f3759df and the fast inverse square root (2012)

125 点作者 carljoseph超过 10 年前

8 条评论

spiritplumber超过 10 年前
If anyone wants a fast atan2 that I wrote a while ago (2007), for making a microcontroller navigate, it&#x27;s at <a href="http:&#x2F;&#x2F;robots-everywhere.com&#x2F;portfolio&#x2F;math&#x2F;" rel="nofollow">http:&#x2F;&#x2F;robots-everywhere.com&#x2F;portfolio&#x2F;math&#x2F;</a>
评论 #8520373 未加载
评论 #8520503 未加载
thewarrior超过 10 年前
Tl;DR :<p>The fast inverse square root is based on the fact that the integer representation of a floating point number is a rough approximation of its logarithm.<p>So convert floating point to its integer representation. So now you have its approximate logarithm. Now take half of that and improve that with some Newton raphson.
评论 #8520362 未加载
评论 #8522532 未加载
simias超过 10 年前
I&#x27;m really impressed by the generalization to other powers, including the regular square root. It&#x27;s the first time I&#x27;ve seen that hack (actually even the author mentions he found nothing on google). I think I could definitely have used that when I needed to compute square roots of fixedpoint numbers with no HW support, it looks very significantly faster than the iterative &quot;by digit&quot; method.
评论 #8520448 未加载
hbbio超过 10 年前
There is also a Wikipedia page for this:<p><a href="http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fast_inverse_square_root" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Fast_inverse_square_root</a>
tempodox超过 10 年前
And the moral of this story is: Never trust any floating-point number whose bits you haven&#x27;t polished yourself.
jokoon超过 10 年前
how does he adjust his σ value ?
agumonkey超过 10 年前
Rarely I&#x27;m that amazed at encodings.
KhalilK超过 10 年前
I may be going on rampage here but &quot;<i>It does contain a fair bit of math</i>&quot; really grinds my gears!<p>Of course it does, it is about square roots and inversions.<p>In most of the cases, in order to optimize an algorithm or solve a problem, mathematics will do it for you, and that ranges from simple arithmetic properties to base changing theorems in linear algebra.<p>You just can not tackle such subjects without expecting it to <i>contain a fair bit of math</i> .
评论 #8519985 未加载
评论 #8520336 未加载
评论 #8519936 未加载