快速开平方的算法
来源:互联网 发布:c语言中 是什么意思 编辑:程序博客网 时间:2024/04/30 01:33
找到了 一个哥们发的快速开平方的算法
和大家一起分享一下
#ifndef _fast_sqrt_18915093_h_
#define _fast_sqrt_18915093_h_
float fast_sqrt(float x);
float fast_invsqrt(float x);
inline float fast_sqrt(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));
}
float fast_invsqrt (float x)
{
float xhalf = 0.5f * x;
int i = *(int*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float*)&i;
return x*(1.5f - xhalf*x*x);
}
#endif //_fast_sqrt_18915093_h_
- 快速开平方的算法
- 最快速的开平方算法
- 单片机开平方的快速算法
- 整数快速开平方算法
- 整数快速开平方算法
- 开平方的算法(转)
- 开平方的七种算法
- 开平方算法
- 开平方算法
- 开平方算法
- 三角函数快速算法(反正切,正余弦,开平方)
- 一种快速开平方并取倒数算法
- 超快速开平方0x5f3759df算法探究
- 快速开平方根算法
- 浮点数快速开平方
- 〖数学算法〗开平方的七种算法
- Quake3 快速开平方和开平方倒数计算优化
- 记录几个开平方算法
- Wireshark使用手记
- 制作system.img(yaffs2) 镜像
- 转载
- 网络营销中待解的难题分析 - 聚锐网
- 操作系统
- 快速开平方的算法
- MFC的模块状态:从AfxGetApp()和AFX_MANAGE_STATE()看MFC的模块状态
- unable to access jarfile ***.jar
- jsp文件下载的几个方法(别人的收藏一下)。。。。。
- neil学英语
- MSDN:OpenSchema 方法 (ADO)
- 打造酷炫风格的Swing界面(2)
- google code jam 08 资格赛A题
- ArcGIS Javascript API 1.2 Released