From b2bf61dbf7b1c83d867f672cd5dad503e92c6362 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Wed, 14 Dec 2005 17:31:16 +0000 Subject: Add and use rand_between. --- misc/subr.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'misc/subr.c') diff --git a/misc/subr.c b/misc/subr.c index f894812..77e3a06 100644 --- a/misc/subr.c +++ b/misc/subr.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -139,3 +140,9 @@ round_to_page(size_t size) size += psize - rem; return size; } + +long +rand_between(long min, long max) +{ + return min + (long)rint((double)random() * (max - min) / RAND_MAX); +} -- cgit 1.4.1