We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Symantic type error on expression
Page Index Toggle Pages: 1
Symantic type error on expression (Read 482 times)
Symantic type error on expression
Mar 28th, 2007, 3:28pm
 
Hi, have the following error on my code.

"Symantic Error: The type of this expression, "float", is not an integral type."

Code:
  int D = numValues;
float d = 0.0;
for (int i=0; i < D; i++) {
d = d + 1.0/(lambda[i]^2.0);
}

d = 1/sqrt(d);


on the line Code:
d = d + 1.0/(lambda[i]^2.0); 

.

Any help would be appreciated. I have tried changing d to a double but still get the same error.

Cheers.
Re: Symantic type error on expression
Reply #1 - Mar 28th, 2007, 3:56pm
 
^2.0 isn't processing/Java syntax for squaring numbers.

You need to use sq(lambda[i]); or the more generic pow(lambda[i],2.0);
Re: Symantic type error on expression
Reply #2 - Mar 28th, 2007, 4:13pm
 
Silly me. Worked it out before your post, trouble was the error wasnt very helpful until i compiled the same code in a java editor which pointed me to the ^, but thanks for putting up with noobish questions.

Andrew
Page Index Toggle Pages: 1