http://d.puremagic.com/issues/show_bug.cgi?id=7993



--- Comment #6 from c.m.brandenb...@gmail.com 2012-04-28 03:38:38 PDT ---
Here's my modified BigUint.divInt() as a proof-of-concept of the fix.

    // return x / y
    static BigUint divInt(T)(BigUint x, T y) if ( is(T==uint) )
    {
        uint [] result = new BigDigit[x.data.length];
        uint b;
        if ((y&(-y))==y)
        {
            assert(y!=0, "BigUint division by zero");
            // perfect power of 2
            for (;y!=1; y>>=1)
            {
                ++b;
            }
        }
        if (1 <= b && b <= 31) {
            multibyteShr(result, x.data, b);
        }
        else
        {
            result[] = x.data[];
            uint rem = multibyteDivAssign(result, y, 0);
        }
        return BigUint(removeLeadingZeros(result));
    }

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

Reply via email to