Main(){ signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); }}

A) 0, -513
B) 512, 0
C) 0, 513
D) 0, 0

Showing Answers 1 - 4 of 4 Answers

louis

  • Mar 29th, 2006
 

Two's complement:

00000000000000001111111111111111 "Not operation" ->

11111111111111110000000000000000 assign to int, since highest position is 1, then Not operation again, ->

10000000000000001111111111111111, then plus 1->

10000000000000010000000000000000, it is - 513

abhimanipal

  • Jan 28th, 2010
 

Answer is A. This is how I reason it out

mBit contains the inverse of bit. All the 1's in bit become 0 and all the 0's in bit become 1. 512 is positive so the result of this inverse has to be a -ve number

bit = bit & ~bit ;
We do a bit wise & operation b/w a number and its inverse. The result has to be 0

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions