This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/33815] tr1::uniform_int isn't uniform
- From: "jkherciueh at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Oct 2007 10:13:02 -0000
- Subject: [Bug libstdc++/33815] tr1::uniform_int isn't uniform
- References: <bug-33815-8718@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from jkherciueh at gmx dot net 2007-10-19 10:13 -------
> Actually, the problem happens only for some specific values of the range, like
> eng.max() / 5.5, dividing by 2 or 10 is ok. Indeed, seems a binary arithmetic
> problem.
I conjecture that the problem happens if and only if the range size does not
divide evenly into eng.max(). In fact, the fractional part determines which
buckets get hit more often. If you do 4.3 instead of 5.5, the first 3 out of 10
or the first 6 ot out 20 buckets get the load. If this conjecture is correct,
it would be more accurate to say that the algorithm performs as promised only
for a small set of range sizes (the divisors of eng.max()) and is biased for
all other values.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33815