tools: change xrand to normal rand c with static variable for seed call

This commit is contained in:
2025-05-07 23:26:48 +02:00
parent ab0c61c474
commit 26f9b93c70
+6 -2
View File
@@ -4,6 +4,7 @@
#define MMOD ((1 << (POW)) - 1) #define MMOD ((1 << (POW)) - 1)
#define SUBA 5 #define SUBA 5
#define SUBB 8 #define SUBB 8
#if 0
int xrand(){ int xrand(){
int mod = MMOD; // (1 << 17) - 1; int mod = MMOD; // (1 << 17) - 1;
int a = (1<<(POW-(SUBA))) - 1; int a = (1<<(POW-(SUBA))) - 1;
@@ -17,7 +18,9 @@ int xrand(){
xi = xii; xi = xii;
return xii; return xii;
/* }
#else
int xrand(){
static bool init = true; static bool init = true;
if(init){ if(init){
init = false; init = false;
@@ -28,8 +31,9 @@ int xrand(){
} }
int ret = rand (); int ret = rand ();
return ret ; return ret ;
*/
} }
#endif
int irand(){ int irand(){
int mod = MMOD; // (1 << 17) - 1; int mod = MMOD; // (1 << 17) - 1;
int a = (1<<(POW-(SUBA))) - 1; int a = (1<<(POW-(SUBA))) - 1;