Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Convert float to char in 89C51

Status
Not open for further replies.

zeby

Newbie level 1
Joined
Feb 10, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
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
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
You could try sprintf?

char buffer[SIZE_OF_FLOAT];

float myFloat = 0.0433;

sprintf(buffer, "%f", myFloat);
 

svicent

Full Member level 6
Joined
Jul 11, 2001
Messages
322
Helped
32
Reputation
62
Reaction score
7
Trophy points
1,298
Activity points
2,293
I think the article "Output Real Numbers", Circuit Cellar #187, February 2006 can help you. The article implements a float to ASCII function.

Regards,
 

eletro

Junior Member level 3
Joined
Sep 12, 2002
Messages
28
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Location
Moon
Activity points
181
#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?
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top