# signed shift question errata

Tony Xu
Greenhorn
Posts: 27
Valiveru Question 1 says both >> and << are signed shift operators. I doubt it. I think only >> is. Please clarify.
By the way, where can I find the colletion of errata for all mock exams in this forum or somewhere else?
Thank you.

Nain Hwu
Ranch Hand
Posts: 139
Yu better believe they are signed operation.
Try this:

[This message has been edited by Nain Hwu (edited October 03, 2001).]

Dave Vick
Ranch Hand
Posts: 3244
Tony and Nain
It think what the question is asking is which ones can effect the sign of the left hand side. However, I think it could have been worded better because Sun uses the word 'signed' in the actual name of the operator. From the JLS section 15.19:
'The shift operators include left shift <<, signed right shift >>, and unsigned right shift >>>'.
What they are refering to is the treatment of the sign of the original value. In the signed right shift >> the operator ensures that the sign of the left hand side remains the same. In the other two it takes no special note of the sign and basically lets whatever happens happen.
hope that helps

------------------
Dave
Sun Certified Programmer for the Javaï¿½ 2 Platform

Tony Xu
Greenhorn
Posts: 27
Nain, thank you, I cannot agree with you though. You cannot take only one example to prove it right, while I can give you one example to prove it wrong. Here it is. Correct me if I am wrong.
int a1 = Integer.MAX;
int b1 = a1 << 1;
System.out.println("a1 is " + a1);
System.out.println("b1 is " + b1);
//////////////////////output
a1 is 2147483647
b1 is -2

Tony Xu
Greenhorn
Posts: 27
Nain, I didn't realize we used the same MAX value. Even though, I think the value of -2 is negative definitly.
Where can I find the errata for all mock exams? I saw in some posts here, somebody said "ok, I put it errata" or something like this. Where is it?

Nain Hwu
Ranch Hand
Posts: 139
Tony,
Dave's statement should clear out your doubt.
I should stress that none of these operators would affect their left-hand operand. It's the value of the whole expression
that depends on the left and right operands.
(ok. I am picky!)
As for eradata, I don't know if there is central place storing it. You might want ask one of the moderators.

Jane Griscti
Ranch Hand
Posts: 3141
Tony,
There's no central place for errata.
Marcus corrects his exams whenever he detects an error. I think Bill Brogden does the same. Some exams aren't maintained any longer.
Exams from books have individual errata pages. You may be thinking of an earlier post by Michael Ernst. The RHE errata page is at http://www.sybex.com/erratatracking.nsf/weberrataform?OpenForm&ISBN=2825
If your looking for a particular question, try using the search function in this forum.
Hope that helps.

------------------
Jane Griscti
Sun Certified Programmer for the Javaï¿½ 2 Platform