diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index cb84f67c8..af28a975d 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -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; } diff --git a/core/todo.txt b/core/todo.txt index e90cc9304..6fa4d2f77 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -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