random()

Math / Random

Description

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

NameTypeDescription
highfloatupper bound
lowfloatlower bound (optional)

Returns

float

Related

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);