If you use the following condition judged the overflow:
(INTMAX - X%10-10*res) < 0,
INTMAX - X%10 < 10*res
When it acctually overflows, 10res is negative, INTMAX - X%10 is positive, the condtion fails, it can not contains the overflow situation. The sign of (INTMAX - X%10-10res) may be positive(can do some experiment), the condition fails, can not contains the overflow.
But use (INTMAX-X%10)/10 < res, it is coducted from INTMAX < 10*res + X%10. transfrom to (INTMAX-X%10)/10 < res, make the both side of the less equation are all positive, the same range. It can satify the purpose. And the value of res belongs to the corrent range.
These are my understand.