learn java
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confused" Watch "confused" New topic


zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
Could you pleas help me to understand this question?

-11 10
why its not 10 -10
thanks in advs......

Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Here's a program that I wrote this morning for the next version of my mock exam.

It prints true,true.
If you want to calculate the negative of any number in two's compliment format, then invert the bits and add one. The ~ operator inverts the bits.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
zaghal mohd
Ranch Hand

Joined: Jun 27, 2002
Posts: 43
Thanks you dan you are doing well in your mock exams good luck and thanks again
Charu Murali
Ranch Hand

Joined: Jul 12, 2002
Posts: 37
You can easily remember the function of ~ operator as " ~X = (-X)-1 ". So in your question ~10 = (-10)-1 = -11.

Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: confused