Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: Ulciscor on June 26, 2005, 03:17:22 PM

Title: Confused
Post 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:
Title: Confused
Post by: Numsgil on June 26, 2005, 04:15:25 PM
I think |X| is absolute value.

modulus is number mod number I think, or number % number in programming.
Title: Confused
Post by: Ulciscor on June 26, 2005, 04:49:45 PM
Look at the first bit of this

Mod (http://mathforum.org/library/drmath/view/63165.html)
Title: Confused
Post by: Numsgil on June 26, 2005, 05:43:38 PM
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).
Title: Confused
Post by: Zelos on October 15, 2005, 02:22:01 PM
I dont get it, what does mod do?
Title: Confused
Post by: Ulciscor on October 15, 2005, 02:30:14 PM
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.
Title: Confused
Post by: Old Henk on October 15, 2005, 02:38:20 PM
So, for example:

4mod2 = 0 (4/2 is exactly 2; there's no remainder)
3mod2 = 1 (3/2 leaves one remainder)
10mod6 = 4

etc.
Title: Confused
Post by: Numsgil on October 15, 2005, 02:39:58 PM
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).