TI公司MSP430G2553芯片中用C语言编程,但开根号sqrt咋用不了

float Q_rsqrt( float number ){ long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) \u0026amp;y; // evil floating point bit level hacking i = 0x5f3759df - ( i \u0026gt;\u0026gt; 1 ); // what the fuck? y = * ( float * ) \u0026amp;i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed #ifndef Q3_VM #ifdef __linux__ assert( !isnan(y) ); // bk010122 - FPE? #endif #endif return 1.0/y;} 不要告诉别人哈,这个sqrt要比库函数的快上4倍~~~
■网友
加上这个""" include \u0026lt;math.h\u0026gt; """ 貌似是,需要载入算数函数库,多看看IDE自带的那些函数库吧(*.h),如果要求不高的话直接调用,如果对指令周期要求比较高的话还是自己写函数吧。
■网友
sqrt()不属于MSP430的标准库里面的,要添加。
■网友
喂喂喂,标签里的TI不是那个TI啊。。。我大dota都可以干德州仪器了?


    推荐阅读