From ce793e31f387c0715fa5b50c20e06510cc3e95ff Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 May 2012 17:15:40 +0000 Subject: Moved random to stable, just needs some minor tweaks. But it's already in use in a couple of core components, including in tempFile name generation. --- src/stable/randombasic.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/stable/randombasic.cpp (limited to 'src/stable/randombasic.cpp') diff --git a/src/stable/randombasic.cpp b/src/stable/randombasic.cpp new file mode 100644 index 0000000..ac591be --- /dev/null +++ b/src/stable/randombasic.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/randombasic.h" + +Bu::RandomBasic::RandomBasic() : + a( 6364136223846793005 ), + c( 1442695040888963407 ), + x( 0 ) +{ +} + +Bu::RandomBasic::~RandomBasic() +{ +} + +void Bu::RandomBasic::seed( int32_t iSeed ) +{ + c = iSeed; +} + +int32_t Bu::RandomBasic::rand() +{ + x = (a*x + c); + return (int32_t)x; +} + -- cgit v1.2.3