hi padmini,
to add the 126 + 127 just do it normally, they get promoted to int so answer is 253. Do you know how to convert to binary from dec? if not
you should review on web somewhere.
Anyway 253 int value in binary code is:
00000000 00000000 ... 111111101 in the low byte
now since it's truncated to a byte again, we only take those last 8 digits and as you know byte is a signed type, so high bit represents sign and the other 7 bits represent the magnitude. Since high bit in this case is 1 the number is negative. Then you just follow procedure to get magnitude, flip bits and add 1.
11111101 becomes
00000010 then + 1
00000011 this is 3 so the number was -3.
does that make sense? don't bother with adding in binary form if you're unsure how to do it, just work out in decimal and then convert the answer to binary.
cheers.
Rich