3 ms·
Because of two's complement and the way implicit conversions work.
by bad_user 16y ago
Because of two's complement and the way implicit conversions work.
- mfukar 16y agoIt is independent of the representation of negative numbers on the machine, because of the conversion rules.
- bad_user 16y agoBecause 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.