www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3739] New: Coding errors in LinearCongruentialEngine

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: baryluk smp.if.uj.edu.pl



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: -------
Jan 24 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3739


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com



09:25:41 PST ---
Makes sense. I operated the changes and will commit soon.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3739


Witold Baryluk <baryluk smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



09:19:31 PST ---
Fixed in DMD 2.040

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2010