mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
make random more random
This commit is contained in:
parent
b39146d9c3
commit
bf067f718a
@ -26,10 +26,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
}
|
}
|
||||||
|
#include "esp8266_peri.h"
|
||||||
|
|
||||||
void randomSeed(unsigned long seed) {
|
void randomSeed(unsigned long seed) {
|
||||||
if(seed != 0) {
|
if(seed != 0) {
|
||||||
srand(seed);
|
srand((seed ^ RANDOM_REG32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ long random(long howbig) {
|
|||||||
if(howbig == 0) {
|
if(howbig == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return rand() % howbig;
|
return (rand() ^ RANDOM_REG32) % howbig;
|
||||||
}
|
}
|
||||||
|
|
||||||
long random(long howsmall, long howbig) {
|
long random(long howsmall, long howbig) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user