From 20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 23 May 2012 00:39:31 +0000 Subject: We have a nice selection of basic randomness functions now. --- src/stable/randombase.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/stable/randombase.cpp') diff --git a/src/stable/randombase.cpp b/src/stable/randombase.cpp index 6514df3..71a5c89 100644 --- a/src/stable/randombase.cpp +++ b/src/stable/randombase.cpp @@ -14,3 +14,18 @@ Bu::RandomBase::~RandomBase() { } +int32_t Bu::RandomBase::rand( int32_t iMax ) +{ + return rand( 0, iMax ); +} + +int32_t Bu::RandomBase::rand( int32_t iMin, int32_t iMax ) +{ + return iMin+(randNorm()*(iMax-iMin)); +} + +double Bu::RandomBase::randNorm() +{ + return (((uint32_t)rand())&0xfffffffeul)/(double)(0xfffffffful); +} + -- cgit v1.2.3