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 12:53:38 +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 #9 from Marc Glisse <marc.glisse at normalesup dot org> 2012-01-27 12:53:38 UTC ---
(In reply to comment #6)
> Marc, can you see a "quick and dirty" (ie, suited for 4.7 too) way to fix this?
Note that I am not a specialist.
1) add an assertion "not implemented yet, try a smaller constant"
2) if you know how to multiply by small a, you can decompose large a into
a1*a2+a3 and perform the operations separately (variants might make sense,
including using powers of 2 and also splitting x)
3) do the double precision operation. longlong.h contains generic code for that
(but beware UDIV_NEEDS_NORMALIZATION).
About comment #7, if that's how you interpret it, it may be worth opening a DR.
I believe the formula has to be interpreted with mathematical, arbitrary size
integers (although of course you can optimize when m*m fits in _Tp).