『优化』一个快速开方的函数(Quake3)

发布时间:2014-10-25 2:23:39
来源:分享查询网

  /* 来至 Quake 3 的源码 */float CarmSqrt(float x){ union{ int intPart; float floatPart; } convertor; union{ int intPart; float floatPart; } convertor2; convertor.floatPart = x; convertor2.floatPart = x; convertor.intPart = 0x1FBCF800 + (convertor.intPart >> 1); convertor2.intPart = 0x5f3759df - (convertor2.intPart >> 1); return 0.5f*(convertor.floatPart + (x * convertor2.floatPart));}

返回顶部
查看电脑版