[Bug libstdc++/33815] tr1::uniform_int isn't uniform
pcarlini at suse dot de
gcc-bugzilla@gcc.gnu.org
Fri Oct 19 11:26:00 GMT 2007
------- Comment #6 from pcarlini at suse dot de 2007-10-19 11:26 -------
Actually, would be:
Index: random
===================================================================
--- random (revision 129456)
+++ random (working copy)
@@ -1607,7 +1607,8 @@
{
typedef typename __gnu_cxx::__add_unsigned<typename
_UniformRandomNumberGenerator::result_type>::__type __utype;
- return result_type(__utype(__urng()) % (__max - __min + 1)) + __min;
+ return result_type((__max - __min + 1.0L) * __utype(__urng())
+ / (__utype(__urng.max()) + 1.0L)) + __min;
}
template<typename _UniformRandomNumberGenerator>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33815
More information about the Gcc-bugs
mailing list