one's complement

I compiled and ran the below program

#include<stdio.h>
int main(){
int d=10;
printf("%d",~d);
return 0;

}

but the output is -11.
can anyone explain the output…thanks in advance.

Bitwise Not( ~ )

The negation operator ("~") is the easiest to understand. It will invert it’s operand (the value it’s used with), so that if we have a variable with a hexadecimal value of 0xF0F0 (1111000011110000), ~0xF0F0 will invert all of the bits in our value to give us 0x0F0F (0000111100001111).

Examples

Initial Values Resulting Value

a b ~a ~b

0 0 1 1

0 1 1 0

1 0 0 1

1 1 0 0

1 Like