Opened 15 years ago

Closed 15 years ago

#186 closed defect (worksforme)

DiscreteUniform::operator(u_long) problem checking bounds.

Reported by: Jari Häkkinen Owned by: Jari Häkkinen
Priority: major Milestone: yat 0.3 (Public release)
Component: random Version: trunk
Keywords: Cc:

Description

In yat/random/random.cc:

The if statement is difficult if n and max is at maximum limit of unsigned integers. The check must be made more elaborate, or the function should be removed:

u_long DiscreteUniform::operator()(u_long n) const
{
	// making sure that n is not larger than the range of the
	// underlying RNG
	if (n>rng_->max())
		throw GSL_error(std::string("DiscreteUniform::op():") + n +
				" is too large for RNG " + rng_->name());
	return gsl_rng_uniform_int(rng_->rng(),n);
}

Change History (1)

comment:1 Changed 15 years ago by Jari Häkkinen

Resolution: worksforme
Status: newclosed

This is not an issue.

Note: See TracTickets for help on using tickets.