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
Posted: Sat Nov 10, 2007 1:40 am
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
Posted: Sat Nov 10, 2007 4:21 am
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
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