www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4452] New: Incorrect result of BigInt ^^ long

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

           Summary: Incorrect result of BigInt ^^ long
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: yebblies gmail.com



BigInt give incorrect results for a^^b for a select set of numbers:

12 ^^ 16
48 ^^ 8
48 ^^ 16
80 ^^ 8
112 ^^ 8
144 ^^ 8
176 ^^ 8
192 ^^ 16
208 ^^ 8
etc

Test case:

void main()
{
  BigInt bpow(long a, long b)
  {
    auto r = BigInt(1);
    while(b--)
      r *= a;
    return r
  }

  foreach(a; 0..1000)
  {
    foreach(b; 0..1000)
    {
        auto r1 = bpow(a, b);
        auto r2 = BigInt(a) ^^ b;
        assert(r1 == r2);
    }
  }
}

Version of std.bigint packaged with dmd2.047
Have not checked on other hardware/os

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 13 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4452


Don <clugdbug yahoo.com.au> changed:

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



Fixed in Phobos svn 1757.

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