The steps taken by that derivation are a bit odd. a - ~b -1 = a-(-b + 1) + 1 is valid (and equals a + b), but it doesn't really make sense as a step. It looks sort of like it's substituting ~b = -b + 1 (which is incorrect) and sort of accidentally fixing it by changing the subtraction at the end to an addition. Very weird.
Sign up to request clarification or add additional context in comments.
Comments
0
You are right that ~ is always 1's complement (aka bitwise not) in c. Where you are going wrong is this: C does not guarantee 2's complement for numbers. So all your calculations depend on using a major flavor of C.
a - ~b -1 = a-(-b + 1) + 1is valid (and equalsa + b), but it doesn't really make sense as a step. It looks sort of like it's substituting~b = -b + 1(which is incorrect) and sort of accidentally fixing it by changing the subtraction at the end to an addition. Very weird.