Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

fast inverse square root explained


    float InvSqrt(float x){
        float xhalf = 0.5f * x;
        int i = *(int*)&x;            // store floating-point bits in integer
        i = 0x5f3759df - (i >> 1);    // initial guess for Newton's method
        x = *(float*)&i;              // convert new bits into float
        x = x*(1.5f - xhalf*x*x);     // One round of Newton's method
        return x;
    }
Source by betterexplained.com #
 
PREVIOUS NEXT
Tagged: #fast #inverse #square #root #explained
ADD COMMENT
Topic
Name
6+3 =