From c73bf4e00f99c8639ea7694478f89d8314afa3db Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 15 Dec 2006 14:57:59 +0000 Subject: [PATCH] * Switch random back to 32 bits. It's enough (tm). --- src/random.c | 11 ++++------- src/random.h | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/random.c b/src/random.c index b6ba1d1..8f142b9 100644 --- a/src/random.c +++ b/src/random.c @@ -27,20 +27,17 @@ #include "random.h" -void zzuf_srand(uint64_t seed) +void zzuf_srand(uint32_t seed) { - uint32_t a = seed & 0xffffffff; - uint32_t b = seed >> 32; - - srand((a ^ 0x12345678) * (b ^ 0x87654321)); + srand(seed ^ 0x12345678); } -uint64_t zzuf_rand(uint64_t max) +uint32_t zzuf_rand(uint32_t max) { if(max <= RAND_MAX) return rand() % max; /* Could be better, but do we care? */ - return (uint64_t)((max * 1.0) * (rand() / (RAND_MAX + 1.0))); + return (uint32_t)((max * 1.0) * (rand() / (RAND_MAX + 1.0))); } diff --git a/src/random.h b/src/random.h index 14cfe03..a331891 100644 --- a/src/random.h +++ b/src/random.h @@ -16,6 +16,6 @@ * random.h: pseudorandom number generator */ -void zzuf_srand(uint64_t); -uint64_t zzuf_rand(uint64_t); +void zzuf_srand(uint32_t); +uint32_t zzuf_rand(uint32_t);