Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1757

Show
Ignore:
Timestamp:
07/14/10 06:59:38 (14 years ago)
Author:
Don Clugston
Message:

Fix bug 4452: Incorrect result of BigInt? long

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/internal/math/biguintcore.d

    r1734 r1757  
    557557        // For example, 10^^100 = (((5^^13)^^7) * 5^^9) * 2^^100. 
    558558        // and 5^^13 still fits into a uint. 
    559559        evenshiftbits  = cast(uint)( (evenbits * y) & BIGDIGITSHIFTMASK); 
    560560        if (x0 == 1) { // Perfect power of 2 
    561561             result = 1UL; 
    562562             return result << (evenbits + firstnonzero*BigDigit.sizeof)*y; 
    563563        } else { 
    564564            int p = highestPowerBelowUintMax(x0); 
    565565            if (y <= p) { // Just do it with pow                
    566566                result = cast(ulong)intpow(x0, y); 
    567                 if (evenshiftbits+firstnonzero == 0) return result; 
     567                if (evenbits + firstnonzero == 0) 
     568                    return result; 
    568569                return result<< (evenbits + firstnonzero*BigDigit.sizeof)*y; 
    569570            } 
    570571            y0 = y/p; 
    571572            finalMultiplier = intpow(x0, y - y0*p); 
    572573            x0 = intpow(x0, p); 
    573574        } 
    574575        xlength = 1; 
    575576    } 
    576577 
    577578    // Check for overflow and allocate result buffer