Skip to content

Commit a7fe5ef

Browse files
authored
Add note that seed should be non-zero (#867)
* Add note that seed should be non-zero After losing about a half hour debugging why my code wasn't deterministic when it should be, I found out that `randomSeed` doesn't do anything when the `seed` is zero (https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/WMath.cpp#L30) * Move warning to new notes and warnings section
1 parent 01b5617 commit a7fe5ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Language/Functions/Random Numbers/randomSeed.adoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Conversely, it can occasionally be useful to use pseudo-random sequences that re
3232

3333
[float]
3434
=== Parameters
35-
`seed`: number to initialize the pseudo-random sequence. Allowed data types: `unsigned long`.
35+
`seed`: non-zero number to initialize the pseudo-random sequence. Allowed data types: `unsigned long`.
3636

3737

3838
[float]
@@ -69,6 +69,11 @@ void loop() {
6969
delay(50);
7070
}
7171
----
72+
[%hardbreaks]
73+
74+
[float]
75+
=== Notes and Warnings
76+
If the `seed` is 0, `randomSeed(seed)` will have no effect.
7277

7378
--
7479
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)