MCPcopy Index your code
hub / github.com/benfry/processing4 / random

Method random

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

Source from the content-addressed store, hash-verified

4688 *
4689 */
4690 public final float random(float high) {
4691 // avoid an infinite loop when 0 or NaN are passed in
4692 if (high == 0 || high != high) {
4693 return 0;
4694 }
4695
4696 if (internalRandom == null) {
4697 internalRandom = new Random();
4698 }
4699
4700 // for some reason (rounding error?) Math.random() * 3
4701 // can sometimes return '3' (once in ~30 million tries)
4702 // so a check was added to avoid the inclusion of 'howbig'
4703 float value;
4704 do {
4705 value = internalRandom.nextFloat() * high;
4706 } while (value == high);
4707 return value;
4708 }
4709
4710 /**
4711 *

Callers 10

choiceMethod · 0.95
random2DMethod · 0.45
random3DMethod · 0.45
anyAlphaMethod · 0.45
startServerMethod · 0.45
initLocationMethod · 0.45
paintMethod · 0.45
drawMethod · 0.45
automateSketchMethod · 0.45
launchVirtualMachineMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected