Thread overview
[Issue 2987] New: D2 phobos BigInt opMul doesn't work correctly
May 16, 2009
rinick@gmail.com
May 16, 2009
ZHOU Zhenyu
May 18, 2009
ZHOU Zhenyu
Aug 28, 2009
Don
May 16, 2009
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 16, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2987


ZHOU Zhenyu <rinick@gmail.com> changed:

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




--- Comment #1 from ZHOU Zhenyu <rinick@gmail.com>  2009-05-15 19:15:31 PDT ---
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

(In reply to comment #0)
> 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 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2987





--- Comment #2 from ZHOU Zhenyu <rinick@gmail.com>  2009-05-17 19:25:38 PDT ---
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 18, 2009
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: -------
August 28, 2009
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




--- Comment #3 from Don <clugdbug@yahoo.com.au>  2009-08-28 05:47:53 PDT ---
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: -------