This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/51795] linear_congruential_engine doesn't work correctly
- From: "3dw4rd at verizon dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Jan 2012 04:48:39 +0000
- Subject: [Bug libstdc++/51795] linear_congruential_engine doesn't work correctly
- Auto-submitted: auto-generated
- References: <bug-51795-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51795
--- Comment #1 from Ed Smith-Rowland <3dw4rd at verizon dot net> 2012-01-27 04:48:39 UTC ---
I random.tcc in _Mod
__x = 1103527590
__m = 2147483648
__a = 1103515245
__c = 12345
static const _Tp __q = __m / __a; // 1
static const _Tp __r = __m % __a; // 1043968403
_Tp __t1 = __a * (__x % __q); // 0
_Tp __t2 = __r * (__x / __q); // 1152047935798738770
if (__t1 >= __t2)
__x = __t1 - __t2; //
else
__x = __m - __t2 + __t1; // 17294696140058296494 !!!
if (__c != 0)
{
const _Tp __d = __m - __x; // 1152047935798738770
if (__d > __c)
__x += __c; // 17294696140058308839
else
__x = __c - __d;
}