Question about number storage in C

As we know any negative number is stored in c language in 2's complement form.

as for example:-

int main() {
    int x=-12;
     printf("%d\n",x);

    x=(~12)

 printf("%d\n",x);
    return 0;
}

Question URL=> http://code.geeksforgeeks.org/mBXMen

12(decimal form)

0000 1100(binary form)

-12=> 2's compliment(0000 1100 ->(flip bits)=1111 0011+(1)=1111 0100(stored in memory))

Q1). when we print -12 then how it print -12.(after storing -12 into 2's compliment)

Q2).how ~(12) prints -13

Author: learnergeek
Login to Answer
Sort By:
Oldest
|
Newest
|
Vote
|
My Answer