# how to calculate modulus of any number?

How do you calculate the modulus of a fractional number, a negative number or a positive number?

Could you explain any example with the whole process?

-
Can you clarify a little? I'm not sure what you are referring to. Do you mean mathematics such as $7 + 5 \equiv 2 \pmod{10}$? –  Niel de Beaudrap Feb 26 '12 at 14:05
Is your question about magnitude of complex numbers, or does it refer to modular arithmetic (in which case "modulus of a number" has no meaning; instead use "number modulo m"). –  Bill Dubuque Feb 26 '12 at 16:41
One way to extend the remainder, or modulo, function $b\mod a$ to a fractional number $b$ is to subtract from $b$ the greatest integer $a\times q$ that is less than or equal to $b$, where $q$ must be an integer.
The operation defined above could be written as $b - a\times \lfloor b/a \rfloor$, where $\lfloor x\rfloor$ represents the greatest integer less than or equal to $x$.
Example. If $b = 5/2$ and $a = 2$, then by the above definition, $b\mod a = 5/2 - 2 \cdot \lfloor (5/2)/2\rfloor = 5/2 - 2 \cdot \lfloor 5/4\rfloor = 5/2 - 2 = 1/2$.