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


Marco Leise <marco.le...@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marco.le...@gmx.de


--- Comment #1 from Marco Leise <marco.le...@gmx.de> 2012-01-31 12:11:35 PST ---
Replace uint with ulong for the longer version ;)
I use this and it is notably faster than what I used before.

uint gcd(uint u, uint v)
{
    int shift;
    if (u == 0 || v == 0) return u | v;
    for (shift = 0; ((u | v) & 1) == 0; ++shift) {
        u >>= 1;
        v >>= 1;
    }
    while ((u & 1) == 0) u >>= 1;
    do {
        while ((v & 1) == 0) v >>= 1;
        if (u < v) {
            v -= u;
        } else {
            uint diff = u - v;
            u = v;
            v = diff;
        }
        v >>= 1;
    } while (v != 0);
    return u << shift;
}

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

Reply via email to