wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Shift by -ve value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Shift by -ve value" Watch "Shift by -ve value" New topic
Author

Shift by -ve value

geetha nagarajan
Ranch Hand

Joined: Jul 13, 2001
Posts: 94
Why is the shift operation by a -ve value ,not a compiler error.(eg: 12 >> -2)?
It compiles fine and gives 0 as o/p.
Pl.clarify.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Doing a shift by a negative number is not a compiler error. It is a legal operation in Java. Do a search in this forum as this topic has been discussed many times.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Shift by -ve value
 
Similar Threads
shift operator 2>>-1 ???
shift operator ~
>> operator
Shift operators - question
Short-cut formula