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
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   69 random(n,n) bug
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: 69 random(n,n) bug  (Read 1245 times)
skloopy

WWW
69 random(n,n) bug
« on: Apr 29th, 2004, 11:57pm »

Okay this is weird..
 
P5 will just stop and not draw anything if you try to use the two variable version of random() and both the values are the same. Like random(10,10) I know nobody would want to do that but if you have a variable that could somehow evaluate to random(0,0) then it'll just stop yr whole sketch
 
I made an example
 
Code:
void setup()
{
  size(100,100);
}
 
void loop()
{
  ellipseMode(CENTER_DIAMETER);
  ellipse(mouseX+(mousePressed ? random(5,5) : 0),mouseY,20,20);
}
« Last Edit: Apr 30th, 2004, 12:09am by skloopy »  
fry


WWW
Re: 69 random(n,n) bug
« Reply #1 on: Apr 30th, 2004, 4:14am »

ha, nice one.
 
it's stuck in an infinite loop because of the fix to another bug--where it's not allowed to include the second param as the result.  
 
it's random [5, 5), so it keeps trying to grab random numbers until it finds one that's not a 5.
 
it's a simple fix, it should just throw an error instead.
 
skloopy

WWW
Re: 69 random(n,n) bug
« Reply #2 on: Apr 30th, 2004, 4:30am »

can it maybe just return 5 instead? like if you say random(5,5)?
 
fry


WWW
Re: 69 random(n,n) bug
« Reply #3 on: Apr 30th, 2004, 5:34pm »

yep. it'll throw an error only in cases of random(6, 4) and that sort of thing.
 
fry


WWW
Re: 69 random(n,n) bug
« Reply #4 on: May 2nd, 2004, 7:18pm »

okee, all fixed for rev 70.
 
Pages: 1 

« Previous topic | Next topic »