What is Modulus?
Date: 06/06/2001 at 17:04:15 From: Bryan Sydnor Subject: Modulus - Why use it, and how do you calculate it? I am a Mechanical Engineer, and am learning to program on my own. I have used the mod command and know what the results mean, but I don't understand the theory behind it and what is actually happening. If you could point me to a book or Web site that would explain what the modulus actually is, its implications in math, and methods for solving it, it would be greatly appreciated. Bryan
Date: 06/07/2001 at 08:53:25 From: Doctor Peterson Subject: Re: Modulus - Why use it, and how do you calculate it? Hi, Bryan. The "mod" operator in computer languages is simply the remainder. For example, 17 mod 3 = 2 because 17 / 3 = 5 rem 2 which in turn means 17 = 3 * 5 + 2 There are some tricky issues when negative numbers are used, but that shouldn't ordinarily be necessary. In math (number theory), the term is used a little differently. The "modulus" is actually not the remainder, but the number you are dividing by; and "mod" is not an operator, but a label telling "in what sense two quantities are considered congruent, or equal." For example, we would say 17 = 11 (mod 3) (read as "17 is congruent to 11, modulo 3"), meaning that 17 and 11 both leave the SAME remainder when divided by 3. You probably won't see this usage if you are only reading about programming, but it's worth being aware of if you look deeper into the math behind it. Here are three references in our archives: Modulus Operator Problem http://mathforum.org/library/drmath/view/55771.html Mod http://mathforum.org/library/drmath/view/55910.html Mod Function and Negative Numbers http://mathforum.org/library/drmath/view/52343.html If this hasn't answered all your questions, please write back and tell me a little more about what you are doing with "mod" and what aspects you don't fully understand. I can probably give you more details if I see what you need to know. - Doctor Peterson, The Math Forum http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994-2015 The Math Forum