[Issue 12958] core.checkedint.mulu is broken

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 24 14:21:21 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12958

--- Comment #4 from David Bregman <uber.daveb at gmail.com> ---
If performance is not a concern, then it's much easier - just use a slow
division to check:

ulong mulu(ulong x, ulong y, ref bool overflow)
{
    immutable xy = x*y;
    if(x && xy/x != y) {
        overflow = true;
    }
    return xy;
}

--


More information about the Digitalmars-d-bugs mailing list