Saturday, January 5, 2008

x+(~x+1)

#include <stdio.h>

void main(void){

int x = 100;
printf("%d",(x+(~x+1)));

}


Answer:
(~x+1) == one's compliment + 1 == two's compliment of x.
The sum of any number and it's 2's compliment is zero.

Complexity: INTERMEDIATE.

No comments: