Just wondering if this exists as a general maths function, in the real world, not in scripting.
Thing is, if it is, my maths coursework = simple
Thanks
Just wondering if this exists as a general maths function, in the real world, not in scripting.
Thing is, if it is, my maths coursework = simple
Thanks
It's in general use in mathematics, where it's called the modulus operator; it's usually written mod instead of %, but that's just a trivial cosmetic difference that has nothing to do with the maths.
wish i understood what u guys were talking about lol. ... :p
There talking about this http://www.php.net/manual/en/language.operators.arithmetic.php unless im mistaken. The last one in the table. Basically a modulas operator % finds the remainder.
Is there a standard way of expressing modulo in mathematics, much like the conventions for simple arithmetic (like addition of numbers)?
So far it seems to me that the books I've read arent consistent.
To find the remainder r of the integer division of integer a by integer b, both of these seem to be in use:
r = a mod b
a = r (mod b)
Strictly speaking, the = should be ≡, because what is being described here is an equivalency relation (a and r both have the same remainder on division by b). Since equivalency relations are by definition symmetric, a≡b and b≡a are ... um ... equivalent ... statements.
For an integer b there are b equivalency classes - one for each modulus - which between them partition the integers. For example, modulo 5, the integers are partitioned into {... -10, -5, 0, 5, 10, ...}, {... -11, -6, -1, 4, 9, ...}, {... -12, -7, -2, 3, 8, ...}, {... -13, -8, -3, 2, 7, ...}, and {... -14, -9, -4, 1, 6, ...}.
The number returned by the modulus operator is merely the "canonical" member of the corresponding class - specifically, the smallest nonnegative one (in the above, they're 0, 4, 3, 2, and 1).
Wheee... a smile, two bangs and modular arithmetic. Next Week: Group Theory or Hausdorff Manifolds.
Thanks for all your help. I was presuming that it was going to be slightly more complicated than how it's used in PHP, but I never expected this!
Anyway, I saw my maths teachers today, and the information here coupled with your explanations really helps, especially Weedpackets; thanks!
I should hopefully be able to get an 8 in at least one of the strands of marking now, presuming I actually get it finished by tomorrow! :bemused: