Calculating Remainder in Report Writer


TechKnowledge Content


Question:

What is the MOD function used for in Report Writer?


Answer:

The MOD function in mathematics returns the remainder of a division. For example, 9 MOD 2 is 1, because 2 divides into 9 four times, with a remainder of 1. A few more examples are 9 MOD 4 = 1, 32 MOD 5 = 2, and 25 MOD 7 = 4.


This function can be expressed by the following formula where R is the remainder, N the numerator, and D the denominator:


R = N - ( D * int( N / D ) )


Using this function to calculate 43 MOD 4:


R = 43 - ( 4 * int( 43 / 4 ) ) = 3




This article was TechKnowledge Document ID:3804