View previous topic :: View next topic |
Author |
Message |
dynamitron
Joined: 18 Mar 2009 Posts: 38
|
Float and constant comparison : what is wrong ? |
Posted: Sat Jun 13, 2009 9:31 am |
|
|
I try to compare a float to a constant (see code below) and I got an error that says that a paren is missing and in fact it is not.
What is wrong ?
Thanks,
D.
Code: |
float temperature [5];
int8 temperature_haut;
if (temperature [0]>25.0)
(
temperature_haut = (int)10 * temperature [0];
) |
Code: |
Executing: "C:\Program files\Picc\CCSC.exe" +FH "rtc_ow.c" I+="C:\Program Files\PICC\Devices" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 58 "rtc_ow.c" Line 799(60,61): Expecting a close paren
*** Error 51 "rtc_ow.c" Line 800(6,7): A numeric expression must appear here
2 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Sat Jun 13 17:11:08 2009
|
Last edited by dynamitron on Sat Jun 13, 2009 10:08 am; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 13, 2009 10:03 am |
|
|
Quote: | float temperature [0]; |
You have declared an array with 0 elements. That's not allowed.
It gives this error:
Quote: | *** Error 45 "pcm_test.c" Line 9(20,21): Subscript out of range |
Please get book on the C language. |
|
|
dynamitron
Joined: 18 Mar 2009 Posts: 38
|
|
Posted: Sat Jun 13, 2009 10:08 am |
|
|
yeah, I know that.
In fact I summarized the code for the post and I made a mistake in the transcript.
The post is corrected now and the question is still there.
D. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 13, 2009 10:14 am |
|
|
Quote: | if (temperature [0]>25.0)
(
temperature_haut = (int)10 * temperature [0];
) |
You're using parens and you should be using braces. |
|
|
|