Standard C math functions fail

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Standard C math functions fail

2,101件の閲覧回数
Wilson
Contributor I
I'm working with a ColdFire MCF5484 running Linux 2.6.10.
Using CodeWarrior for ColdFire ISA, Linux Platform Ed. v 2.0

The standard math library calls (sin(), cos(), log10(), etc) have been giving me bogus answers. A simple example: log10(100.0) returns "-inf" (and not 2).

Another observation:

#include
#include
static double getPI2() { return M_PI/2.0); }
static double getV() {return 1.0; }

int main(int argc, char** argv)
{
double v1 = sin(M_PI_2);
double v2 = 1.0 * sin(getPI2());
double v3 = getV() * sin(getPI2());

printf("%f, %f, %f\n", v1, v2, v3);

return 0;
}

Produces:
"1.000000, 1.000000, -0.000000"

What is it about calling a function that would corrupt a simple calculation like this?

I see the same problem on both the Logic PD ColdFire dev kit (M5485EVB) and our hardware. Do I need to explicitly enable floating point support somewhere? Is there a patch for CodeWarrior?

I thought the MCF548x had all sorts of great hardware floating point support, including multiply/accumulate instructions. Very confused and frustrated!
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

840件の閲覧回数
mkhademism
Contributor I
I have the same problem with MCF5485 and codewarrior 6.4 for floating point functions.
I add this library (C_4i_CF_FPU_MSL.a ) to my project.
sqrt( ) works properly but sin( ) and cos( ) doesn't work?
Is it the problem of compiler or library ?
if so, Is this problem solved in codewarrrior 7.0?

0 件の賞賛
返信

840件の閲覧回数
MattSPI
Contributor I
I ran into the same problem,

Does CodeWarrior use gcc3.4? The 3.4 seems to target the m68k which does not include the advanced math support.

I am currently using gcc4.1 supplied by http://www.codesourcery.com It works great with the math support, and my applications runs noticably faster.
0 件の賞賛
返信