[Bug libstdc++/51795] linear_congruential_engine doesn't work correctly
marc.glisse at normalesup dot org
gcc-bugzilla@gcc.gnu.org
Fri Jan 27 13:55:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51795
--- Comment #14 from Marc Glisse <marc.glisse at normalesup dot org> 2012-01-27 13:35:29 UTC ---
(In reply to comment #12)
> I see. Before asking: 26.5/4 says that "all descriptions of calculations in
> this subclause use mathematical real numbers".
Ok, no need to ask then.
> Thus should we use floats?!?
Actually, using double is a common trick (that wouldn't be sufficient here):
compute (double)a*(double)x/(double)m and round it to an integer q; then you
can compute a*x-m*q modulo 2^64.
More information about the Gcc-bugs
mailing list