快速求平方根

2020-12-17  本文已影响0人  人气小哥

float mySqrt(float x)
{
float a = x;
unsigned int i = *(unsigned int *)&x;
i = (i + 0x3f76cf62) >> 1;
x = *(float *)&i;
x = (x + a / x) * 0.5;
return x;
}
误差千分之6

参考网址:
https://blog.csdn.net/xtlisk/article/details/51249371

上一篇下一篇

猜你喜欢

热点阅读