AnsweredAssumed Answered

Floating point operations causing global variable corruption

Question asked by Gopal Amlekar on Mar 29, 2011
Latest reply on Mar 29, 2011 by Gopal Amlekar

Hi,

 

I am new to Freescale development. Using a MC9S08DZ60 board for my project. I have created a project in Eclipse 10.1 version using support for IEEE32 type floating point.

 

My project uses a couple of floating point operations and 5 global variables. Whenever I attempt to do a floating point arithmetic operation with integer or character type, the global variables are getting modified unneccessarily.

For e.g. when I try to typecast an integer to float type or add / subtract a float variable with integer / character, my global variables are getting corrupted.

 

Can somebody please guide me where I am going wrong?

 

Here is portion of code, which is causing this behaviour:

 

void HexToASCII(float Slip, char *String){char i;unsigned long intPart, FractPart;float tempfloat;unsigned long templong;tempfloat = Slip;intPart = (unsigned long) Slip;tempfloat = (Slip - (float) intPart); /* This behaviour is observed here after executing this line and all further lines */tempfloat = tempfloat * 10;FractPart = (unsigned long) tempfloat;

 

 

 

 

Thanks..

Outcomes