Modulo reference page question

I was reading through some code trying to figure out exactly how it worked and came across the modulo (%) symbol. Not knowing what it was lead me to the arduino reference page and i found it very confusing. Im by no means an expert in arduino, C++ or mathematics, so sorry if this is a dumb question, but the description says 'Calculates the remainder when one integer is divided by another. It is useful for keeping a variable within a particular range (e.g. the size of an array). ' and the examples then say

x = 7 % 5; // x now contains 2
x = 9 % 5; // x now contains 4
x = 5 % 5; // x now contains 0
x = 4 % 5; // x now contains 4

but 7÷5=1.4 not 2, 9÷5=1.8, is there something im missing or was the word 'divided' the wrong term to use? as i said im no expert, just a normal person trying to figure all this out on my own so any clarification would be greatly appreciated, thanks

7%5 ==> 5 goes into 7 once with 2 remainder (15+2 = 7)
9%5 ==> 5 goes into 9 once with 4 remainder (1
5+4 = 9)
5%5 ==> 5 goes into 5 once without a remainder (15+0 = 5)
4%5 ==> 5 goes into 4 zero times with 4 remainder (0
5+4 = 4)

16%5 ==> 5 goes into 16 3 times with 1 remainder (3*5+1 = 16)

That help?

David

yea that does help understand it bit better but i could always tell what the person who wrote that was getting at, i was just confused by the wording. division isn't really the best term to use is it? wouldn't something else convey the idea in a less confusing manor? like absolute value? think thats the term i mean, its been a long time since i had a math class

Modulo is defined as the 'remainder' after one 'divides'.

It is related to the term 'base'.

Base-10 is equivalent to modulo-10, so we count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ...
.. note that the units column repeats 0, 1, ..., 9, 0, 1, ...
Modulo-10 on 0, 1, 2, 3 ... would give 0, 1, 2, 3, ..., 9, 0, 1, 2, ..., 9, 0, 1, 2

Similarly for Base-2, or binary: 0, 1, 10, 11, 100, 101, 110, ...
Modulo-2 on 0, 1, 2, 3, .... would give 0, 1, 0, 1, 0, 1, ...

Modulo is useful to step through an array, for example:

  int array[7];
  for(int i=0; i<100; i++) {
    Serial.println(array[i%7];
  }

David