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: nob...@puremagic.com ReportedBy: bary...@smp.if.uj.edu.pl --- Comment #0 from Witold Baryluk <bary...@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: -------