Is it possible for an explicit cast of, say, int32_t
to uint32_t
, to alter the bit representation of the value?
For example, given that I have
If the value is in the range of both the signed and the unsigned types, then both the value and representation are unchanged by conversions.
Otherwise, the signed-to-unsigned conversion is only allowed to preserve the bit representation when the implementation's representation of negative values for the type is twos-complement. For ones complement or sign-magnitude, it conversion must change the representation. The conversion in the other direction is implementation-defined, so it may or may not change the representation.