MCPcopy Index your code
hub / github.com/processing/processing / random

Method random

core/src/processing/core/PApplet.java:5112–5130  ·  view source on GitHub ↗
(float high)

Source from the content-addressed store, hash-verified

5110 *
5111 */
5112 public final float random(float high) {
5113 // avoid an infinite loop when 0 or NaN are passed in
5114 if (high == 0 || high != high) {
5115 return 0;
5116 }
5117
5118 if (internalRandom == null) {
5119 internalRandom = new Random();
5120 }
5121
5122 // for some reason (rounding error?) Math.random() * 3
5123 // can sometimes return '3' (once in ~30 million tries)
5124 // so a check was added to avoid the inclusion of 'howbig'
5125 float value = 0;
5126 do {
5127 value = internalRandom.nextFloat() * high;
5128 } while (value == high);
5129 return value;
5130 }
5131
5132 /**
5133 * ( begin auto-generated from randomGaussian.xml )

Callers 13

random2DMethod · 0.80
random3DMethod · 0.80
shuffleMethod · 0.80
shuffleMethod · 0.80
shuffleMethod · 0.80
shuffleMethod · 0.80
shuffleMethod · 0.80
startServerMethod · 0.80
defaultLocationMethod · 0.80
paintMethod · 0.80
drawMethod · 0.80
automateSketchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected