4 Replies Latest reply on Dec 16, 2011 4:19 AM by JulianWigman

# How to calculate Remainder/Modulo from two integers

Hello all,

how do I create a calculation that returns the remainder from an integer division?

E.g:

10 divided by 3 -> Returns 1

Any help would be much appreciated.

Thanks,

• ###### 1. Re: How to calculate Remainder/Modulo from two integers

Hi

As part of your calculation, you may need to import System.Math as well, and use the DivRem method.  See http://msdn.microsoft.com/en-us/library/yda5c8dx.aspx#Y856 for details.  I haven't actually tried it, but hopefully that may set you on the right track.

Cheers

Paul

1 of 1 people found this helpful
• ###### 2. Re: How to calculate Remainder/Modulo from two integers

Hi

I'd have thought the easiest way was to use the MOD operator as this returns the remainder.

So in a calculation:

Remainder of 10 divided by 3

would be:

10 % 3

Simples

Julian

• ###### 3. Re: How to calculate Remainder/Modulo from two integers

Thank you Julian.

That did the job!

• ###### 4. Re: How to calculate Remainder/Modulo from two integers

Thats good.  remember to flag as solution.