When you do uint16_t(2)+int16_t(-3)
, both operands are types that are smaller than int
. Because of this, each operand is promoted to an int
and signed + signed
results in a signed integer and you get the result of -1
stored in that signed integer.
When you do uint32_t(2)+int32_t(-3)
, since both operands are the size of an int
or larger, no promotion happens and now you are in a case where you have unsigned + signed
which results in a conversion of the signed integer into an unsigned integer, and the unsigned
value of -1
wraps to being the largest value representable.