random()
Math / RandomDescription
Generates random numbers. With one argument, returns a value from 0 up to (but not including) the parameter. With two arguments, returns a value from the first to the second.
Syntax
float random(float high)
float random(float low, float high)
Parameters
| Name | Type | Description |
|---|---|---|
| high | float | upper bound |
| low | float | lower bound (optional) |
Returns
floatRelated
Under the Hood
From Processing.h:
float random(float lo, float hi);
float random(float hi);
Under the Hood
From Processing.cpp:
float PApplet::random(float lo, float hi) {
return lo + _rngDist(_rng) * (hi - lo);
}
float PApplet::random(float hi) { return random(0.f, hi); }
float PApplet::random(float hi) { return random(0.f, hi);