Skip to content

Commit

Permalink
make random more random
Browse files Browse the repository at this point in the history
  • Loading branch information
Links2004 committed Jan 29, 2016
1 parent b39146d commit bf067f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cores/esp8266/WMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@
extern "C" {
#include <stdlib.h>
}
#include "esp8266_peri.h"

void randomSeed(unsigned long seed) {
if(seed != 0) {
srand(seed);
srand((seed ^ RANDOM_REG32));
}
}

long random(long howbig) {
if(howbig == 0) {
return 0;
}
return rand() % howbig;
return (rand() ^ RANDOM_REG32) % howbig;
}

long random(long howsmall, long howbig) {
Expand Down

0 comments on commit bf067f7

Please sign in to comment.