PowerTip: Return remainder after dividing two numbers

Doctor Scripto

Summary: Use Windows PowerShell to return the remainder after dividing two numbers.

Hey, Scripting Guy! Question How can use Windows PowerShell to divide two numbers and only return the remainder (called a modulo operation)?

Hey, Scripting Guy! Answer In Windows PowerShell, the modulo operator is the % sign. Here are a few examples of how to use it:

PS C:\> 3 % 2

1

PS C:\> 5 % 2

1

PS C:\> 11 % 2

1

0 comments

Discussion is closed.

Feedback usabilla icon