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
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://www.haomeiwen.com/subject/fxjzgktx.html
网友评论