Modulo Operation

Modulo Operation



In computing, the modulo operation, sometimes also called "remainder" or "rest", gives the remainder from a division. It finds the remainder of division of one number by another.

In general, when talking about arithmetic operations, we recognize the following operations:

OperationSyntaxResult
Additiona + bthe sum of a and b
Subtraction a - bb subtracted from a
Negation- aminus a
Multiplicationa * ba multiplied by b
Divisiona / ba divided by b
Moduloa % bthe remainder of a division between a and b

Given two numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder, on division of a by n.

For example, if you divide 7 by 3, 3 goes in 7 two times. But there is a remainder of 1, and that is the result of the modulo operation.

The expression "9 mod 3" would evaluate to 0.

Although typically performed with a and n both being integers, many computing systems allow other types of numeric operands. There are various ways of defining a remainder, and computers and calculators have various ways of storing and representing numbers, so what exactly constitutes the result of a modulo operation depends on the programming language and/or the underlying hardware.

With floating-point division, such as in 9.0 / 4.0, the result is a floating-point value, in this case 2.25. But with integer division, such as in 9 / 4, the result is only the integer part, in this case 2.

Modulo in calculators

Some calculators have a mod() function button, and many programming languages have a mod() function or similar, expressed for example as mod(a,n).

Some calculators display expressions on the keyboard that say "%", "mod", or "Mod" as a modulo or remainder operator, such as a % n or a mod n.

.

Discuss this article or this topic in our discussion forum:
(The table bellow shows a list of 8 most recent topics posted in our discussion forum. Visit our discussion forum to see more. It is possible the links below are not related to this page, but you can be certain you will find related posts in the discussion forum. You can post one yourself too.)
Email this article to a friend:
TO: 
FROM: 
2 + 6 - 3 = 
.
How can I link to this web page?

It is easy, just include the code provided below into your HTML code.

<a href="http://www.maxi-pedia.com/modulo+operation" title="www.Maxi-Pedia.com: Modulo Operation" target="_blank">Modulo Operation</a>
.