Framework (A-Z)

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Name

random()

Examples
int val;
// Sets val to a random number between -40 and 40
val = random(-40, 40);  

int x;
// Sets x to a random number between 0 and 5
x = random(5);
Description Generates random numbers. Each time the random() function is called, it returns an unexpected value within the specified range. If one parameter is passed to the function it will return a float between zero and the value of the parameter. The function call random(5) returns values between 0 and 5. If two parameters are passed, it will return a float with a value between the the parameters.
Syntax
random(value1);
random(value1, value2);
Parameters
value1 int or float
value2 int or float
Returns float
Usage Application
Related randomSeed()
Updated on July 07, 2011 11:08:50pm PDT

Creative Commons License