View previous topic :: View next topic |
Author |
Message |
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
int variable to double |
Posted: Sat Apr 12, 2008 11:40 am |
|
|
If i need to use a value to have a decimal value, how do i declare that variable?
I need to take an analog value of say 85 and divide it by 52.2. Then display that decimal value. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Sat Apr 12, 2008 12:08 pm |
|
|
Thanks. Got it working. I used the float declaration but in the printf of the lcd i never changed %u to %f.
That example program works well, thanks. |
|
|
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Sat Apr 12, 2008 12:15 pm |
|
|
can you please explain this part of the program to me.
"\f%3.2f",
in the following line
printf(lcd_putc, "\f%3.2f", x1); |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Apr 12, 2008 12:29 pm |
|
|
You need to get a book on the C language, or use online tutorials.
For your question, you can do a search with http://www.google.com
for this:
Quote: | printf width precision |
Here is one result. Look down at the bottom of this page to see how
the width and precision values affect the output.
http://irc.essex.ac.uk/www.iota-six.co.uk/c/c3_more_on_format_specifiers.asp
Also be aware that CCS doesn't always follow the full C standard
with regard to printf. In other words, there may be some differences
in the displayed result, compared to the Microsoft MSVC compiler. |
|
|
|