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: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Oct 2007 10:49: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 #5 from pcarlini at suse dot de 2007-10-19 10:49 -------
To wit, this kind of change, you can certainly apply it to the 4.2.1 headers
as-is:
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())
+ / (__urng.max() + 1.0L)) + __min;
}
template<typename _UniformRandomNumberGenerator>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33815