added a few const, and a default value for the generate(int) call

This commit is contained in:
Paolo Cignoni 2008-12-18 00:29:03 +00:00
parent c2c940338e
commit 0b15c9b4b4
1 changed files with 335 additions and 335 deletions

View File

@ -112,7 +112,7 @@ public:
}
/// Return a random number in the given range (limit) using the Subtractive Ring method.
unsigned int generate(unsigned int limit)
unsigned int generate(unsigned int limit= 0xffffffffu)
{
_M_index1 = (_M_index1 + 1) % 55;
_M_index2 = (_M_index2 + 1) % 55;
@ -123,7 +123,7 @@ public:
/// Return a random number in the [0,1) real interval using the Subtractive Ring method.
double generate01()
{
unsigned int lmt = 0xffffffffu;
const unsigned int lmt = 0xffffffffu;
unsigned int number = generate(lmt);
return static_cast<double>(number) / static_cast<double>(lmt);
}