www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2987] New: D2 phobos BigInt opMul doesn't work correctly

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2987

           Summary: D2 phobos BigInt opMul doesn't work correctly
           Product: D
           Version: 2.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: rinick gmail.com


It won't pass this test

 BigInt a = 10;
 BigInt b = a * a;
 foreach (i; 0..100)
 {
    assert(a * a == b);
    a *= i;
    b *= i * i;
 }

To fix this bug.
Find this around BigInt.d line 907

    c = updateShr(c);

replace it with

    c = updateUShr(c);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 15 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2987


ZHOU Zhenyu <rinick gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rinick gmail.com





The test code should be.
  BigInt a = 10;
  BigInt b = a * a;
  foreach (i; 2..100)
  {
     assert(a * a == b);
     a *= i;
     b *= i * i;
  }

sorry for the typo


 It won't pass this test
 
  BigInt a = 10;
  BigInt b = a * a;
  foreach (i; 0..100)
  {
     assert(a * a == b);
     a *= i;
     b *= i * i;
  }
 
 To fix this bug.
 Find this around BigInt.d line 907
 
     c = updateShr(c);
 
 replace it with
 
     c = updateUShr(c);
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2987






Created an attachment (id=375)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=375)
patch to fix bug 2987

fix the bug (line 907)

add a testcase

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2987


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|bugzilla digitalmars.com    |andrei metalanguage.com




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2987


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED





Thanks!
Actually both cases of updateShr should probably be updateUShr, although AFAICT
the result of the second one is never actually used, so it's a bit irrelevant.
Fixed in svn 1251.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2009