3 ms·
Because of two's complement, "-1" as a signed int/long is internally represented with all bits set to 1. Conversion rules are pretty basic, i.e. there is no co
by bad_user 16y ago
Because of two's complement, "-1" as a signed int/long is internally represented with all bits set to 1.
Conversion rules are pretty basic, i.e. there is no conversion done on the actual value, so that's why it works: converting "-1" to an unsigned int yields MAX_UINT.
- mfukar 16y agoWhat I mean is that the conversion: unsigned int flags = -1; always works, regardless of whether negative numbers are represented in two's complement, one's complement, or sign/magnitude on the underlying hardware.