Viewing a single comment thread. View all comments

brimston3- t1_itrypm8 wrote

If -1 would overflow then the type is unsigned and the if x &lt; 0 check is too late; unsigned < 0 is never true. You must check the magnitude of the subtrahend against the minuend before the operation.

3