wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why does System.out.println( ~4 ) equal -5 ? 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 "Why does System.out.println( ~4 ) equal -5 ?" Watch "Why does System.out.println( ~4 ) equal -5 ?" New topic
Author

Why does System.out.println( ~4 ) equal -5 ?

Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206


C:\Documents and Settings\Harry Henriques>java Question
-5
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Hi,

check this thread: Bitwise Complement


JDBCSupport - An easy to use, light-weight JDBC framework -
Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Thanks Sebastian.




C:\Documents and Settings\Harry Henriques>java Question
-5
-4
-5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Remember that bitwise operators (except | and &) and shift operators are not a part of the SCJP exam...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
Don't get me started about those stupid light bulbs.
 
subject: Why does System.out.println( ~4 ) equal -5 ?