Skip to content

Commit b5b45a3

Browse files
committed
force random function to wrap at 32 bits
1 parent be42d77 commit b5b45a3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

cpp/arduino/Godmode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ long random(long vmax)
3838
{
3939
GodmodeState* godmode = GODMODE();
4040
godmode->seed += 4294967291; // it's a prime that fits in 32 bits
41+
godmode->seed = godmode->seed % 4294967296; // explicitly wrap in case we're on a 64-bit impl
4142
return godmode->seed % vmax;
4243
}
4344

0 commit comments

Comments
 (0)