www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6819] New: BigInt ^^ fails for some big numbers (powers)

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

           Summary: BigInt ^^ fails for some big numbers (powers)
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: redhatbugzilla yopmail.com



16:16:40 PDT ---
With dmd 2.055 under Linux x86-64, (BigInt(10)^^p)^^2 doesn't return the
correct result starting from p == 32:

import std.stdio, std.bigint;
void main() {
    for( int p = 0 ; p < 40 ; p++ ) {
        BigInt n = BigInt(10)^^p;
        BigInt a = n*n;
        BigInt b = n^^2;
        if( a != b ) {
            writefln( "%s %s %s %s", p, n, a, b );
        }
    }
}

It also fails with BigInt(2)^^p (from p==32 too) and BigInt(20)^^p (from
p==16).

Values like (BigInt(2)^^32+1)^^2 are computed correctly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6819


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
         OS/Version|Linux                       |All
           Severity|normal                      |critical



Ouch. There's a shift by 32 missing. Looks like a fencepost error. Raising to
critical.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6819


Don <clugdbug yahoo.com.au> changed:

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



https://github.com/D-Programming-Language/phobos/commit/1d3a9d22766a3dbcb0063ef907f3e0dd32382a6d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 20 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6819




05:29:20 PDT ---


I've just built and tried latest git (dmd2+druntime+libphobos2) and both the
small test above and my original program that triggered the bug now work
correctly. Thanks!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2011