|
发表于 2007-10-27 15:24:00
|
显示全部楼层
Re:float型转DWORD的问题
恩,谢谢funcman。
看到了!
float InvSqrt(float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x; // get bits for floating value
i = 0x5f375a86- (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;
}
牛顿迭代法我都忘了怎么用了,再学习一下。
|
|