[Bug libstdc++/51795] linear_congruential_engine doesn't work correctly
3dw4rd at verizon dot net
gcc-bugzilla@gcc.gnu.org
Fri Jan 27 07:01:00 GMT 2012
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;
}
More information about the Gcc-bugs
mailing list