D already has them: https://github.com/D-Programming-Language/druntime/blob/master/src/core/checkedint.d
Druntime's checkint.d should be modify:
uint subu(uint x, uint y, ref bool overflow)
{
if (x < y)
return y - x;
else
return x - y;
}
ulong subu(ulong x, ulong y, ref bool overflow)
{
if (x < y)
return y - x;
else
return x - y;
}
Frank
