Re: A new classification method for RNGs: Significance Level
On Jul 13, 5:48 pm, Pete Becker <p...@versatilecoding.com> wrote:
On 2008-07-13 10:11:09 -0400, vipps...@gmail.com said:
[...]
How is it redundant? If the caller asks for a range that's
larger than this distribution can handle and this check
isn't present, the algorithm will not return values that
cover the requested range.
Whether that second if is present or not, the behavior of
the algorithm is the same.
It should produce an error. The fact that it doesn't means
it's wrong, not that it's redundant.
=46rom a quality of implementation point of view. Formally, the
contract is to return a number in the given range. The single
statement "return 0;" meets that requirement, and you don't need
all of this extra testing:-).
Of course, the specification did state that the "range can be
maximally RAND_MAX + 1", so normally, I would expect an
assertion failure if my argument wasn't in this range. Or
totally undefined behavior, but not the function arbitrarily
changing my argument.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34