Assume you are performing 2s complement arithmetic in a comp
Assume you are performing 2\'s complement arithmetic in a computer with 8-bit registers. After the following code is run,
signed char a = -12, b = 125, c;
c = a - b;
the binary value of c would be _________ and the decimal value of c would be _______ when printed out.
Assume you are performing 2\'s complement arithmetic in a computer with 8-bit registers. After the following code is run,
signed char a = 119, b = 123, c;
c = a + b;
the binary value of c would be _______ and the decimal value of c would be ________ when printed out.
Solution
1) 10001100 ( -12 IN BINARY) - 01111101 ( 125 IN BINARY)
= 10001100 + 10000010 (NEGATE)
= 00001110 ( Since output can be in 8 digits only .. others will be discarded)
= + 14 (decimal)
2) 119+123
01110111 + 01111011
011110010 ( Binary)
242 (decimal)
Feel free to ask any doubt. Kindly rate up if satisfied.
