| Author |
Message |
zeby
Joined: 10 Feb 2006 Posts: 1
|
10 Feb 2006 16:00 Convert float to char in 89C51 |
|
|
|
|
hey
i would like to convert a float number (ie: 0.0433) into a IEEE char[32]
i need this function in order to save a float number in an eeprom of 8bits words
can u help me?
Zeb
|
|
| Back to top |
|
 |
btbass
Joined: 20 Jul 2001 Posts: 1187 Helped: 113 Location: Oberon
|
10 Feb 2006 19:27 Convert float to char in 89C51 |
|
|
|
|
You could try sprintf?
char buffer[SIZE_OF_FLOAT];
float myFloat = 0.0433;
sprintf(buffer, "%f", myFloat);
|
|
| Back to top |
|
 |
Google AdSense

|
10 Feb 2006 19:27 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
svicent
Joined: 11 Jul 2001 Posts: 413 Helped: 23
|
10 Feb 2006 19:39 Re: Convert float to char in 89C51 |
|
|
|
|
I think the article "Output Real Numbers", Circuit Cellar #187, February 2006 can help you. The article implements a float to ASCII function.
Regards,
|
|
| Back to top |
|
 |
eletro
Joined: 12 Sep 2002 Posts: 28 Location: Moon
|
11 Mar 2006 21:06 Re: Convert float to char in 89C51 |
|
|
|
|
#define byte unsigned char
byte *app_float;
float var = 1.232;
app_float = &var;
write_eeprom(*app_float++);
write_eeprom(*app_float++);
write_eeprom(*app_float++);
write_eeprom(*app_float);
it is correct?
|
|
| Back to top |
|
 |