Re: [algogeeks] bitwise operator confusion

2010-08-08 Thread sharad kumar
in case of -ve numbers irrspectiveof size of compilerits repesented as in remanig space apart from the space of binaryequivalent of number.hence u get On Sun, Aug 8, 2010 at 9:37 PM, navin wrote: > Assunming, integer is 2 byte, What will be the output of the program? > > #include > > i

Re: [algogeeks] bitwise operator confusion

2010-08-08 Thread jalaj jaiswal
sign bit gets extended in case of negative numbers On Sun, Aug 8, 2010 at 9:37 PM, navin wrote: > Assunming, integer is 2 byte, What will be the output of the program? > > #include > > int main() > { >printf("%x\n", -1>>1); >return 0; > } > > [A]. > [B].0fff > [C]. >

[algogeeks] bitwise operator confusion

2010-08-08 Thread navin
Assunming, integer is 2 byte, What will be the output of the program? #include int main() { printf("%x\n", -1>>1); return 0; } [A]. [B].0fff [C]. [D].fff0 Answer: Option A i dont understand why it produces actually -1 = there shoud be one bit zero ( i