Mod


Definition: Divides two numbers and returns only the remainder.

 

The Mod operator is a bit of an odd duck (although it doeshave its uses): it divides two numbers and then returns the remainder. In Windows PowerShell you can achieve the same effect by using the % operator. For example, this command divides 28 by 5, then stores the remainder in the variable $a:

 

$a = 28 % 5

 

When you run this command and then echo back the value of $ a youshould get the following:

 

3