Mohamed Othman

Floating point storing

Discussion created by Mohamed Othman on Dec 15, 2006
Latest reply on Dec 15, 2006 by Mohamed Othman
I am using an external serial flash memory for my HCS12.
I want to store floating point numbers in this flash. can anybody please tell me if the following
is the right way to deal with floating point storage.
suppose we have "d" as a floating point number.
float d ;
float *pt ;
char i;
for (i=0; i<=3;i++)
  send_serial (*(pt++)); // send_serial, is a function to send a byte through the SPI0.
Now for reading the stored floating point number and send it to the SCI0
char buffer[4];              // a temporary buffer to store the 4bytes of the stored floating point number.
float *pt=&buffer;
for (i=0;i<=3;i++)
  get_serial (*(pt++)); // get_serial is a function to receive one byte from the SPI0.
 printf ("%6.3F",pt);   // send the received floating point number to the SCI0.
thanks a lot and I appriciate any help here.