Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Yet another erratum  RSS feed

 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
It seems I am debugging Mughal's mock exam these days...
Here is what I believe to be yet another (the 3rd I've found thus far) erratum:
QUESTION:
Which statements are true concerning the effect of the >> and >>> operators?
The following answer is considered to be correct:
(d) The value returned by >>> will never be negative as long as the value of the right operand is equal to or greater than one.
Here is a counterexample to prove the non-correctness of the answer:
-1 >>> 32
The value of this expression (-1) is negative, even though the value of the right operand is >= 1.
Panagiotis.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. This one I believe was talked about before here. But as you show, it can be negative. Question should also state if the value of left mod right does not equal 0.
Bill
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!