LCDInfo.com

http://www.lcdinfo.com
It is currently Mon Nov 25, 2024 11:08

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Mar 13, 2004 18:19 
Offline

Joined: Sat Mar 13, 2004 18:16
Posts: 2
Can anyone please show me a sample C code to convert floating point and integer to BCD/ASCII? I want to display it on 16x2 alphanumeric LCD.
For ex. I want to display "0.5" etc. on LCD which are in float data types.

I am using SDCC compiler for 8051. However code for any compiler will do unless it is not using any in-built library functions.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 20:53 
Offline

Joined: Tue Feb 18, 2003 23:28
Posts: 78
char buffer[255];

double/float yourvar;

sprintf(buffer, "%d" , yourvar);

buffer than consists your var as string
for %d u can use the standard c conventions like %f %.2f and so on ....


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 21:12 
Offline

Joined: Sat Mar 13, 2004 18:16
Posts: 2
Thanks. I'll try that out. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group