Panagiotis Varlagas

Ranch Hand

Posts: 233

posted 16 years ago

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

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.

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

posted 16 years ago

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

Bill