Reference for Wiring version 0024+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
| Name |
random() |
| Examples |
int val;
val = random(-40, 40); // Sets val to a random number between -40 and 40
int x;
x = random(5); // Sets x to a random number between 0 and 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 January 11, 2010 09:42:02pm PST