CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Point's in LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Userrr



Joined: 09 Jul 2004
Posts: 40
Location: Europe

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

Point's in LCD
PostPosted: Thu Aug 26, 2004 12:20 pm     Reply with quote

Using 2x20 LCD, I must printf to LCD value float , but how put to this
value after cents, thouthands, millions
example:
value = 9123567,5 in float
at LCD I must printf: 9.123.567.5 of ...
Ttelmah
Guest







Re: Point's in LCD
PostPosted: Thu Aug 26, 2004 2:39 pm     Reply with quote

Userrr wrote:
Using 2x20 LCD, I must printf to LCD value float , but how put to this
value after cents, thouthands, millions
example:
value = 9123567,5 in float
at LCD I must printf: 9.123.567.5 of ...

If this is being used for currency, forget floats, and use a 32bit integer instead. Otherwise you will have perpetual errors from the rounding inherent in floats. Have the integer count in 'cents', and it will be exact.
There are two different approaches to outputing the number. First, printf it, to a _fixed length_ output string, using sprintf. Use the option to display leading zeros, so the digits will allways be in the same place in the string. Then start at the left end of the string, use a counter to know where in the string you are, skip the zeros, and output the digits from the string when you get to them. When the counter corresponds to the positions you want the markers added, send these.
Alternatively, you can extract digits from a number using division, and subtraction, and use these the same way. However again the numeric accuracy of floats will give problems.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group