diff options
author | Dennis Friis <peavey@placid.dk> | 2008-11-03 20:52:28 +0000 |
---|---|---|
committer | Dennis Friis <peavey@placid.dk> | 2008-11-03 20:52:28 +0000 |
commit | cbe24b20cb2c2286485aa69de077fc63b7d8a51d (patch) | |
tree | beaf0f4aed4f4331f8fcfbe2268313df428ce47e | |
parent | a7f3726a0a7f16bccb664871fe35e8d2f2572f00 (diff) | |
download | tmwa-cbe24b20cb2c2286485aa69de077fc63b7d8a51d.tar.gz tmwa-cbe24b20cb2c2286485aa69de077fc63b7d8a51d.tar.bz2 tmwa-cbe24b20cb2c2286485aa69de077fc63b7d8a51d.tar.xz tmwa-cbe24b20cb2c2286485aa69de077fc63b7d8a51d.zip |
Add 2 defines for rand() that uses hi-order bits to get slighty better pseudo-random numbers
-rw-r--r-- | src/common/utils.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common/utils.h b/src/common/utils.h index 29463cf..fa5cf57 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -31,3 +31,5 @@ if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\ { printf("SYSERR: realloc failure"); abort(); } } while(0) +#define MRAND(max) (int) ((float)max * (rand() / (RAND_MAX + 1.0))) +#define MMRAND(min, max) min + (int) ((float)max * (rand() / (RAND_MAX + (float)min))) |