Chris Lardi

Standard C math functions fail

Discussion created by Chris Lardi on Dec 11, 2006
Latest reply on Aug 31, 2008 by mohammad khademi
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:

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;

"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!