C | Data Types | Question 7
Assume that the size of char is 1 byte and negatives are stored in 2’s complement form
Explanation: 125 is represented as 01111101 in binary and when we add 10 i.e 1010 in binary it becomes : 10000111. Now what does this number represent?
Firstly, you should know that char can store numbers only -128 to 127 since the most significant bit is kept for sign bit. Therefore 10000111 represents a negative number. To check which number it represents we find the 2’s complement of it and get 01111001 which is = 121 in decimal system. Hence, the number 10000111 represents -121.
Quiz of this Question
My Personal Notes arrow_drop_up
Please Login to comment...