Adding UniformVariable::GetInteger and using it to fix bug in RealRandomStream::GetNext.
This commit is contained in:
@@ -274,6 +274,11 @@ double UniformVariable::GetValue(double s, double l)
|
||||
return ((UniformVariableImpl*)Peek())->GetValue(s,l);
|
||||
}
|
||||
|
||||
uint32_t UniformVariable::GetInteger (uint32_t s, uint32_t l)
|
||||
{
|
||||
NS_ASSERT(s <= l);
|
||||
return static_cast<uint32_t>( GetValue(s, l+1) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -200,6 +200,13 @@ public:
|
||||
*/
|
||||
double GetValue(double s, double l);
|
||||
|
||||
/**
|
||||
* \brief Returns a random unsigned integer from the interval [s,l] including both ends.
|
||||
* \param s Low end of the range
|
||||
* \param l High end of the range
|
||||
* \return A random unsigned integer value.
|
||||
*/
|
||||
uint32_t GetInteger (uint32_t s, uint32_t l);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ RealRandomStream::RealRandomStream ()
|
||||
uint32_t
|
||||
RealRandomStream::GetNext (uint32_t min, uint32_t max)
|
||||
{
|
||||
return static_cast<uint32_t> (round (m_stream.GetValue (min, max)));
|
||||
return m_stream.GetInteger (min, max);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user