• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ques. from JTips Mock 1

 
Vijay Narayanan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True or False?
Unsigned Right Shift on a Negative Integer always returns
a Positive Integer.
The answer is False.
I feel it should be True. Plz someone explain...
 
Adrian Muscalu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This have been recently discussed here, on this forum. The answer is relative simple since -1 >>> 32 returns -1. This is one case that should clear any doubts.
Best regards
 
Vijay Narayanan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could anyone tell me how -1>>>32 has been evaluated. bcoz i tried it out and i got -1 as the answer
 
Vijay Narayanan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the binary representation of -1.
 
Jim Petersen
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijay
This should help!
http://www.jchq.net/tutorial/BitShift.htm
rgds Jim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic