• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

signed shift question errata

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yu better believe they are signed operation.
Try this:

[This message has been edited by Nain Hwu (edited October 03, 2001).]
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic