Skip to content

Commit 3f4daaa

Browse files
committed
Add note about max parameter to random() reference page
Closes #70
1 parent 8915a2c commit 3f4daaa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Language/Functions/Random Numbers/random.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void loop() {
8585
If it is important for a sequence of values generated by `random()` to differ, on subsequent executions of a sketch, use `randomSeed()` to initialize the random number generator with a fairly random input, such as `analogRead()` on an unconnected pin.
8686

8787
Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling `randomSeed()` with a fixed number, before starting the random sequence.
88+
89+
The `max` parameter should be chosen according to the data type of the variable in which the value is stored. In any case, the absolute maximum is bound to the `long` nature of the value generated (32 bit - 2,147,483,647). Setting `max` to a higher value won't generate an error during compilation, but during sketch execution the numbers generated will not be as expected.
8890
[%hardbreaks]
8991

9092
[float]

0 commit comments

Comments
 (0)