aspose file tools
The moose likes Java in General and the fly likes is my understanding of the remainder operator correct? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "is my understanding of the remainder operator correct?" Watch "is my understanding of the remainder operator correct?" New topic
Author

is my understanding of the remainder operator correct?

James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

I'm reading the operators chapter in the SCJP book and just want to confirm that my understanding of this operator is correct.


Means, 3 can fit into 10 3 times, and we are left with 1. therefore y will be 1

z = 2 because 4 fits into 10 twice, and leaves a remainder of 2?

I couldn't find a better way of explaining it, but is this correct?


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11808
    
  18

you got it.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20039
    
  30

But take care when using negative numbers. Is -10 % 4 2, or is it -2? And what about 10 % -4 and -10 % -4? (Hint: try it out)


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
 
subject: is my understanding of the remainder operator correct?
 
It's not a secret anymore!