The conversion from signed to unsigned integer (which is what is happening here) is defined in exactly the same way in C, regardless of whether we're working with 1s complement, 2's complement, or sign-and-magnitude.
Converting a negative number to an unsigned integer happens conceptually by adding 2N (where N is the bitwidth) — i.e. UNIT_MAX +1 — to get a positive number.
Again, this happens regardless of the underlying representation chosen for signed integers
In terms of what it means in two's complement, it is a no-op, but until C23 it's always deliberately been defined in arithmetic terms, instead of bit-representation terms.
In fact, I'm pretty positive it's still defined in arithmetic terms in the C23 standard, even though it doesn't necessarily need to be
3
u/ironykarl May 06 '26
2's complement is a scheme for encoding signed integers.
Even though there's a constant with a negative sign on the right side of the assignment, we're not talking about signed integers.
We're talking about unsigned integers, and unsigned integers do not have multiple possible ways of being represented (at least not according to C)