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 support@ccsinfo.com

Printf & floating numbers

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



Joined: 05 Jul 2004
Posts: 1

View user's profile Send private message Send e-mail

Printf & floating numbers
PostPosted: Mon Jul 05, 2004 2:12 am     Reply with quote

Hi!
Whenever i try to send a floating point number to an lcd usin printf function then someting strange happens.e.g if i send 2.30 then the number that is actually displayed is 2.29, similarly if i send 2.00 then the number 1.99 is displayed. What might be causing this?
Confused
_________________
"Planet Earth, a place for peacelovers"
Paolino



Joined: 19 Jan 2004
Posts: 42

View user's profile Send private message

PostPosted: Mon Jul 05, 2004 2:41 am     Reply with quote

Which compiler version are you using? Which PIC? Can you post a little bit of code, please?

Paolo.
Guest








Re: Printf & floating numbers
PostPosted: Mon Jul 05, 2004 3:36 am     Reply with quote

waseem wrote:
Hi!
Whenever i try to send a floating point number to an lcd usin printf function then someting strange happens.e.g if i send 2.30 then the number that is actually displayed is 2.29, similarly if i send 2.00 then the number 1.99 is displayed. What might be causing this?
Confused


nothing wrong but simple truncation

there are no such thing as 2.3000000 in PIC, what stored in PIC memory is actuall something like 2.299999, because CCS float only use 32 bit, the accuracy is around 1.2e-7, try this then you will see some more digits

float x = 2.3;
printf("%f", x)
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