aboutsummaryrefslogtreecommitdiff
path: root/src/stable/randombase.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-05-23 00:39:31 +0000
committerMike Buland <eichlan@xagasoft.com>2012-05-23 00:39:31 +0000
commit20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3 (patch)
treeec6174abd3a21f8d803d26267f9c03ddc468746e /src/stable/randombase.cpp
parentce793e31f387c0715fa5b50c20e06510cc3e95ff (diff)
downloadlibbu++-20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3.tar.gz
libbu++-20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3.tar.bz2
libbu++-20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3.tar.xz
libbu++-20ee81a7b2d44ec985e99b4ee1bcd08fa25175d3.zip
We have a nice selection of basic randomness functions now.
Diffstat (limited to 'src/stable/randombase.cpp')
-rw-r--r--src/stable/randombase.cpp15
1 files changed, 15 insertions, 0 deletions
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()
14{ 14{
15} 15}
16 16
17int32_t Bu::RandomBase::rand( int32_t iMax )
18{
19 return rand( 0, iMax );
20}
21
22int32_t Bu::RandomBase::rand( int32_t iMin, int32_t iMax )
23{
24 return iMin+(randNorm()*(iMax-iMin));
25}
26
27double Bu::RandomBase::randNorm()
28{
29 return (((uint32_t)rand())&0xfffffffeul)/(double)(0xfffffffful);
30}
31