[Issue 4452] New: Incorrect result of BigInt ^^ long

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 13 04:50:34 PDT 2010


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 at puremagic.com
        ReportedBy: yebblies at gmail.com


--- Comment #0 from yebblies <yebblies at gmail.com> 2010-07-13 04:50:21 PDT ---
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: -------


More information about the Digitalmars-d-bugs mailing list