javascript相当于*(float *)& i

时间:2017-10-03 05:50:07

标签: javascript bit

我不是很擅长c,那么javascript相当于*(float *)& i?

或更好,是什么是

的javascript等价物
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;
}

0 个答案:

没有答案