mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
fix to prevent random(lo, hi) from returning hi (fixes #4551)
This commit is contained in:
@@ -4921,7 +4921,13 @@ public class PApplet implements PConstants {
|
||||
public final float random(float low, float high) {
|
||||
if (low >= high) return low;
|
||||
float diff = high - low;
|
||||
return random(diff) + low;
|
||||
float value = 0;
|
||||
// because of rounding error, can't just add low, otherwise it may hit high
|
||||
// https://github.com/processing/processing/issues/4551
|
||||
do {
|
||||
value = random(diff) + low;
|
||||
} while (value == high);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
0241 (3.1.2)
|
||||
X rewrite csv handling
|
||||
X fix parsing bugs, remove newlines option, improve performance
|
||||
X prevent random(low, high) from returning 'high'
|
||||
X https://github.com/processing/processing/issues/4551
|
||||
|
||||
gohai
|
||||
X Fix GLExceptions on Raspberry Pi when using offscreen PGraphics
|
||||
|
||||
Reference in New Issue
Block a user