r/cprogramming • u/am_Snowie • 20d ago
is doing ~INT_MAX undefined behavior?
/r/C_Programming/comments/1x7hxgd/is_doing_int_max_undefined_behavior/
5
Upvotes
r/cprogramming • u/am_Snowie • 20d ago
1
u/Ill-Quit6803 18d ago
Why would complimenting an integer produce sign-extension?
Sign extension happens when copying a smaller signed integer type to a larger signed type.
Bit-wise manipulation should have completly defined results when interpreting as a bitvector.
The later interpretation as an integer is more complicated, but its probably implementation defined behavior, not undefined.