   How on earth is modulo returning this value?
  Hi guys.I rarely use modulo but for some tutorials I'm working through they use it. I always understood modulo to return the remainder of two numbers that were divided, I double checked online to make sure I was correct, but I have no clue how it is returning this value. Am I missing something?I have the following just as an example:temp = 10 % 15;Somehow when I print it temp its giving me 10. I am at a complete loss to how this happens. If I type 10/15 in the calculator I get 0.67. I understand that the language I'm using (Objective-C) modulus only works with integer values so any result would be truncated but...I'm still confused.The most I can understand is that if I change the 10 to 20 I get a correct result (5) but if I do any number lower then 15 then that number is what is returned after the expression evaluates.For example:temp = 7 % 15;Will end up being 7. Is there an explanation to why this happens?   
  That's exactly the values it should return. What do you expect modulo to do instead?10 can not be evenly divided by 15, so its division remainder is 10."20 % 15" would be 5."30 % 15" would be 0.Are you maybe mentally flipping the sides of the two operands?If you expected 5 to be the result in your first example, write it as "temp = 15 % 10;"   ;  It´s totally normal!20 / 15 = 1 //(+5)10 / 15 = 0 //(+10)You can´t divide 10 by 15 so you will get 10 as a result.   ;  Ah ok sorry I was being an idiot. Thank you guys for the explanation :)I was overthinking and making things more complicated then they should be :D   ;  It's actually quite simple. Lets take a look at this code.int x = 10 / 15;And the modulus operator returns the 'left over' after the division so something like this...int x = 10 % 15;Is actually the same as...int x = 10 - (10 / 15) * 15;;  hi,10 % 15 = 10 because 10 cannot be divided by 15.You can see x % y as the following :while (you can divide x with y (which means x/y>=1) ){  x = x - y ;}e.g 16 % 15 = 1.note the above pseudocode may not be 100% correct (e.g for negative numbers), but it will give you an idea how it works.the symbol / in the calculation is not modulo but div.x  |  y---------   | div   |mod|thanks   