Menu Close

How the Negative Integer Numbers are Stored in Memory

Computer uses special mechanism to store negative numbers which is 2’s complement format.

Before going to that, let’s have a look on 1’s complement of a number.

1’s complement of a number

1’s compliment of number is just inverting binary bits of an actual number.

2’s complement of a number

To get 2’s complement of a number, just add 1 to 1’s complement of an actual number.

This 2’s complement form will be stored in computer. 

Both one’s complement and two’s complement can not change the sign bit (MSB)

When we declare a negative integer variable,

int i;
i=-10;

The memory will assign above memory for -10 ( 16 bit system )

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Related Posts

Leave a Reply