This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/51795] linear_congruential_engine doesn't work correctly


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;
        }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]