Representing negative no. in binary form

When you convert -5 in binary form, it is written as 1011 as we flip 0101 and add 1 to it. But isn’t it also equal to 7.

sorry not 7 , i mean 11

hi @rishabhindora, for a signed integer computer uses MSB (most significant bit) to identify whether is number is positive or negetive , 1 for negetive and 0 for positive, let’s take integer as a 8-bit number than 5 is represented as 00000101 (since MSB here is zero , computer will percieve it as a positive number) now when we talk about -5 we take 2’s compliment of 5 i,e (11111010+1=11111011) .
Now when computer gets (11111011) it checks its MSB first i.e 1 thus its a negetive number , now for negetive number it takes it’s 2’s compliment to convert it back into its original value which will be (00000100+1=00000101) which is 5 and add a -ve sign to it as its already determined to be a negative number , thus we get output as -5. i hope i cleared your doubt

In case you still have some query feel free to ask :slight_smile:
If you got the answer then mark your doubt as resolved