cbinarybit

What is 0 - (-128) with 2's complement notationequal to?


I am struggling to understand if there is any overflow with the following equation using 8 bit signed integers.
0b00000000 - 0b10000000


Solution

  • This question is tagged c, and in C, all arithmetic in types lower-rank than int gets promoted to int, and int has at least 16-bit range, so (signed char)0-((signed char)-128) is just 128.