logoalt Hacker News

skydhashtoday at 12:17 PM1 replyview on HN

Wouldn’t be better to check both inputs before against the max value of that type instead of actually doing the overflow?


Replies

Retr0idtoday at 12:18 PM

There are lots of better ways of doing this, but knowing why this one is bad/wrong requires the mental model described upthread.

(But also, what you describe would be incorrect, since two <MAX values can add to a value that is >MAX, and overflow)

show 1 reply