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: "marc.glisse at normalesup dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Jan 2012 13:35:29 +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 #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.