[Issue 3739] New: Coding errors in LinearCongruentialEngine
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 24 09:12:48 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3739
Summary: Coding errors in LinearCongruentialEngine
Product: D
Version: 2.039
Platform: x86
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: baryluk at smp.if.uj.edu.pl
--- Comment #0 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2010-01-24 09:12:47 PST ---
First at the end of class, wrong initalization.
- private UIntType _x = m ? a + c : (a + c) % m;
+ private UIntType _x = m ? (a + c) % m : (a + c);
};
Second in this method we can assome that if m is 0, and type is int, it was
really 2^^32 (0 in int).
private static bool properLinearCongruentialParameters(ulong m,
ulong a, ulong c) {
+ static if (is(UIntType == uint)) {
+ if (m == 0) m = (1uL << 32);
+ }
// Bounds checking
if (m == 0 || a == 0 || a >= m || c >= m) return false;
// c and m are relatively prime
This problems are orthogonal to the my proposed optimalisations in bug3738.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list