IvanaXu / iDeepRec

DeepRec For Me https://github.com/alibaba/DeepRec
https://deeprec.readthedocs.io/zh/latest/index.html
Apache License 2.0
3 stars 1 forks source link

part2 🍎 x1.3 sqrt /rsqrt //Quake 3 #71

Closed IvanaXu closed 1 year ago

IvanaXu commented 1 year ago

https://www.cnblogs.com/me115/archive/2011/02/16/1956134.html

float InvSqrt(float x){

       float xhalf = 0.5f*x;

       int i = *(int*)&x; // get bits for floating value

       i = 0x5f3759df - (i>>1); // gives initial guess y0

       x = *(float*)&i; // convert bits back to float

       x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy

       return x;

}