From cbe24b20cb2c2286485aa69de077fc63b7d8a51d Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Mon, 3 Nov 2008 20:52:28 +0000 Subject: Add 2 defines for rand() that uses hi-order bits to get slighty better pseudo-random numbers --- src/common/utils.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/common') 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))) -- cgit v1.2.3-60-g2f50