I am using microchip c18 and i have this function which splits the float in to 4 respective bytes.And C18 follow little endianess
a[0]=*(fptr); address 0
a[1]=*(fptr+1); 1
a[2]=*(fptr+2); 2
a[3]=*(fptr+3); 3
and writes in to serial eeprom.
If i wanted to read back the float variable.
float read_float(void)
{ float f;
unsigned char *fptr;
fptr=&f;
*(fptr)=eepromread(0);
*(fptr+1)=eepromread(1);
*(fptr+2)=eepromread(2);
*(fptr+3)=eepromread(3);
return(f);
}
Will this function return the float variable?. I'm devoid of any hardware and simulation tools right now.
I trust I'm clear on my question. edit:
While doing so. a compiler mismatch error occurs on assigning char to float..How could i remove the error?