Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is my understanding of the remainder operator correct?

 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12202
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you got it.
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic