Skip to content

Latest commit

 

History

History
 
 

fastInvSqrt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Fast InvSqrt() 扩展阅读

地址

代码

最牛逼的代码,O(1)时间复杂度计算平方根!

float InvSqrt (float x) {
    float xhalf = 0.5f * x;
    int i = *(int*)&x;
    i = 0x5f3759df - (i >> 1);
    x = *(float*)&i;
    x = x * (1.5f - xhalf * x * x);
    return x;
}