Fast Inverse Square Root 手動推導過程紀錄
來源
https://www.youtube.com/watch?v=p8u_k2LIZyo
IEE 754
https://www.h-schmidt.net/FloatConverter/IEEE754.html
Mantissa is
Exponent is
取
化簡
quake 的作者利用數學上的技巧偷了一點近似值
當x 數字很小的時候就越接近x 自己,當x 在 0 到 1 之間
加上變數,可以調整這個範圍減少整體的平均面積(總之就是減少整體誤差)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
繼續化簡
變化一下
所以跟上面的IEEE 754 找到相同的
就是代表跟
把IEEE 754 的float 數字當作long 來操作,但是不進行轉換
得到記憶體位置,然後把整體當作long 的樣子來操作,最後取值。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
介紹一下基本知識
magic number 的主要計算過程
然後想要求解的是:
當中魔法數字:
向右位移:
輸入:
牛頓接近法