Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some help with Shift operators

 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about everyone else, but I just came across a methiod in the Integer class , which gives binary representation of any int.
You can try things like these and decide for yourself how different values get shifted.
System.out.println(Integer.toBinaryString(-1));
System.out.println(Integer.toBinaryString(2));
There is a similar method in the Long class as well.
Of course I'm sure every one knows of the toBinaryString () and toHexString() methods of Integer and Long classes.

Hope this helps
 
Arathi Rajashekar
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks shivaji.
I never bothered of checking this. But now I got the idea. And one more thing, about passport book. Even I find lot of mistakes in that book. But there is no errata as per my knowledge. We have to write the code and we have to find the answer ourself
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That book has such blatant errors. I bought it becuase it was written by a lot of ranchers. I assumed that it must be really good- the authors must have had first hand experience of studying for certification etc.
But I am thoroughly disappointed....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic