Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Do you know that in MSVC uint16_t(50000) + uin16_t(50000) == -1794967296?

Not only is that insane code and both my compiler and static analysis go for my throat, it's also not true. I think the argument is supposed to be about unsigned integer overflow, but the numbers don't add up. The big negative number wraps to 63744. And the sum (100K) wraps to 34464.



It seems the intent was for "*" to be used instead of "+". At which point it's actually undefined behavior even though the operands are unsigned!


that makes more sense!




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: