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

how to get 2 digits from float

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








how to get 2 digits from float
PostPosted: Fri Nov 09, 2007 6:41 pm     Reply with quote

Hello, can any1 tell me please how to get 2 digits and one decimal digit from a float value?
Ex: float i=128.4;
I need to get 28.4

thank you all
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 10, 2007 1:40 am     Reply with quote

Is the purpose to extract these digits so they can be displayed ?

You could use the sprintf() function. This will convert the floating point
value into an ASCII string and put it in a buffer. You can then scan the
buffer and find the location of the decimal point. Then you will know
where the other digits are located in the buffer, and you can display them.
Guest








PostPosted: Sat Nov 10, 2007 4:21 am     Reply with quote

PCM programmer wrote:
Is the purpose to extract these digits so they can be displayed ?

You could use the sprintf() function. This will convert the floating point
value into an ASCII string and put it in a buffer. You can then scan the
buffer and find the location of the decimal point. Then you will know
where the other digits are located in the buffer, and you can display them.

Figures,
i need to show it on several 7 segments. Sprintf might help me.
thank you very much,
regards
Guest








PostPosted: Wed Nov 21, 2007 9:21 am     Reply with quote

http://www.edaboard.com/viewtopic.php?t=150005
http://www.coolcircuit.com/project/meter/index.html

Bye
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