FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Software Bugs
(Moderator: fry)
   function return and int()?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: function return and int()?  (Read 2056 times)
lunetta

7200475272004752 WWW Email
function return and int()?
« on: May 2nd, 2004, 1:18am »

hello to all processers
 
I have a simple question on function syntax;
 
int test() {
return( int(5.5) );
}
void setup() {}
void draw() {
println(test());
}
 
Why this doesn't work, while
 
int test() {
int x = int(5.5);
return( x );
}
void setup() {}
void draw() {
println(test());
}
 
this works? any particular reason?
 
(sorry about the dumb question, I just want to understand the concept behind this...)
 
Thanks to all!
 
arielm

WWW
Re: function return and int()?
« Reply #1 on: May 2nd, 2004, 2:43am »

one syntax that always work when "type-casting" is, e.g:
Code:
(int) 5.5

like in
Code:
int test()
{
  return (int) 5.5;
}

 
concerning the "int(something)" syntax, i think it's not in the java language, but rather a helper provided by the processing preprocessor (the same way: assigning a value of 5.5 instead of 5.5f to a float will work in processing but not with a standard java compiler...)
 

Ariel Malka | www.chronotext.org
lunetta

7200475272004752 WWW Email
Re: function return and int()?
« Reply #2 on: May 2nd, 2004, 3:18am »

thanks Ariel!
 
by the way, you just made me realize that if I erase the parenthesis out of the return statement, it works... I'll start to use the other syntax anyway. Real Thanks!
 
fry


WWW
Re: function return and int()?
« Reply #3 on: May 4th, 2004, 12:56am »

hm, that stinks.. preprocessor bug..
 
Pages: 1 

« Previous topic | Next topic »