I'm a little baffled to discover -1u is exactly 0xFFFFFFFF — the maximum value of unsigned int.
I would have expected a type error.
Likely there's some important code out there that relies on this strange behavior.
I would have expected a type error.
Likely there's some important code out there that relies on this strange behavior.
> Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
https://stackoverflow.com/questions/50605/signed-to-unsigned...
Signed integer underflow/overflow is UB, on the other hand.