|
Author |
Topic: int(random()); wierdness (Read 442 times) |
|
gkoshra
|
int(random()); wierdness
« on: May 15th, 2003, 12:30pm » |
|
Hello, i've had a problem with this before, and i'm not sure what's wrong with it... Code:int ytarget = int(random(h))-int(random(50)); |
| Gives me this error... Syntax error: found'(' I'm positive that there shouldn't be anything wrong with this. Is it something to do with the amount of ints i've liberally spread around?
|
|
|
|
toxi
|
Re: int(random()); wierdness
« Reply #1 on: May 15th, 2003, 12:47pm » |
|
not sure either, what's going on here... seems like a bug, but in anyway a more elegant (and working) version of this line would look like this: int ytarget=int(random(h)-random(50));
|
http://toxi.co.uk/
|
|
|
edwardgeorge
|
Re: int(random()); wierdness
« Reply #2 on: May 15th, 2003, 6:39pm » |
|
try (int)'s instead of int() eg Code:int ytarget = (int)random(h)-(int)random(50); |
|
|
Ed, Suppose, Nottingham, UK http://www.suppose.co.uk http://ed.suppose.co.uk
|
|
|
gkoshra
|
Re: int(random()); wierdness
« Reply #3 on: May 16th, 2003, 10:51am » |
|
Thanks guys. I had gotten round the problem, but I thought i'd post it and see whether there was some fundamental thing I was doing wrong. Cheers.
|
|
|
|
REAS
|
Re: int(random()); wierdness
« Reply #4 on: May 20th, 2003, 3:10pm » |
|
the parser has problems with "int()" sometimes. we're currently working on replacing the current parser with something more reliable. the java native "(int)" will always work. i come across this problem often while coding with Processing. it's frustrating, i know.
|
|
|
|
Martin
|
Re: int(random()); wierdness
« Reply #5 on: May 21st, 2003, 4:14pm » |
|
int ytarget = (int)(random(h)-random(50)); should work just fine. less typing of (int)'s
|
|
|
|
benelek
|
Re: int(random()); wierdness
« Reply #6 on: May 23rd, 2003, 11:50am » |
|
it may matter little, but just for the hell of further correctness:- Code:(int)(random(a)-random(b)); |
| will statistically produce different results to Code:((int)random(a)-(int)random(b)); |
|
|
|
|
|
Martin
|
Re: int(random()); wierdness
« Reply #7 on: May 23rd, 2003, 1:34pm » |
|
there's a little diff there but you just want something random. at any rate, it would matter in cases 3 + 4... int a,b; a = b = 50; println( "1 \\ " + (int)(random(a)-random(b))); println( "2 \\ " + ((int)random(a)-(int)random(b))); println( "3 \\ " + (int)(3.142675-2.581158 )); println( "4 \\ " + ((int)3.142675-(int)2.581158 ));
|
|
|
|
fry
|
Re: int(random()); wierdness
« Reply #8 on: Jun 24th, 2003, 9:45pm » |
|
these sort of things will be fixed soon with a new parser that will be arriving from dan mosedale.
|
|
|
|
fry
|
Re: int(random()); wierdness
« Reply #9 on: Sep 2nd, 2003, 2:10am » |
|
the parser has arrived and will be in rev 60. so these bugs are now fixed.
|
|
|
|
|