Saturday 21 October 2017

memory representation for negative values

Memory representation of for 16bit compiler.

signed int a=-7;       
signed short int a=-7 
Binary equivalent of data 7 in 16 bit:  00000000 00000111
Binary equivalent of data -7 will be its 2’s complement:
1’s complements of 00000000 00000111 is 11111111 11111000
2’s complement will be:




Binary equivalent of data -7 in 16 bit: 11111111 11111001
Data bit: 1111111 11111001 (Take first 15 bit form right side)
Sign bit: 1                 (Take leftmost one bit)
First eight bit of data bit from right side i.e. 00000111 will store in the leftmost byte from right to left side and rest seven bit of data bit i.e. 1111111 will store in rightmost byte from right to left side as shown in the following figure:   

No comments:

Post a Comment