brimston3- t1_itrypm8 wrote
Reply to comment by HaikuBotStalksMe in [WP] You are an NPC in an RPG. Normally, your attack is set to 1. However, a player used a cursed item on you, reducing your attack by 2, causing it to underflow, making you the most powerful in the game. by alegonz
If -1 would overflow then the type is unsigned and the if x < 0
check is too late; unsigned < 0 is never true. You must check the magnitude of the subtrahend against the minuend before the operation.
Viewing a single comment thread. View all comments