Darwinbots Forum
Code center => Darwinbots Program Source Code => Topic started by: Ulciscor on June 26, 2005, 03:17:22 PM
-
I just realised...
in school we got taught that |X| is said as 'mod X' and returns the absolute value of X, I.e. it's magnitude.
But then there is Xmod2 which is the remainder when X is divided by 2.
Or have I just totally made up the |X| bit? I might have dreamt it or something I am not sure.
:unsure:
-
I think |X| is absolute value.
modulus is number mod number I think, or number % number in programming.
-
Look at the first bit of this
Mod (http://mathforum.org/library/drmath/view/63165.html)
-
Okay, there are actually two conecpts.
Modulus is the absolute value.
Modulo is the remainder of integer division (and has some other definitions as well that are similar).
-
I dont get it, what does mod do?
-
As I said, 4mod2 is the remainder when 4 is divided by 2. This is modulo. Modulus is the absoloute value, the magnitude of a number regardeless of sign. Mod is probably used most commonly as the first definition.
-
So, for example:
4mod2 = 0 (4/2 is exactly 2; there's no remainder)
3mod2 = 1 (3/2 leaves one remainder)
10mod6 = 4
etc.
-
Definition of mod:
a (mod n) = b means that:
n*q + b = a where b < n, b >= 0, and q is some integer.
That's the math definition anyway, I think computer mods allow for b to be < 0 (that is, just the remainder of integer division).