🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators modulus
This page was created by Charles on 2025-11-18. Last edited by Wikiadmin on 2026-08-17.

You can calculate an IEEE remainder in OCL when you need the value left by a division calculation; this page is for MDriven Designer users writing numeric expressions.

Use IEEE remainder in OCL

In C#, the modulus expression 5 % 3 returns the remainder of the division. In OCL, use the IEEERemainder operation instead:

5.IEEERemainder(3)

This expression returns 2.

The operation takes a number as its argument and returns an integer:

number.IEEERemainder(divisor)

For example, if an OCL expression has an integer-valued attribute named EmployeeCount, you can evaluate its IEEE remainder after division by 2:

EmployeeCount.IEEERemainder(2)

Do not treat IEEE remainder as modulus

IEEERemainder is not mathematically equivalent to the % remainder operator. The two operations use different formulas and can return different values for the same dividend and divisor. Use IEEERemainder when the OCL expression requires the IEEE-defined operation; do not copy a C# % expression into OCL unchanged.

For the IEEE formula and the distinction from the remainder operator, see Documentation:OCLOperators Number::ieeereminder(r:Number):Integer. For the MDriven-specific comparison with C# modulus, see Documentation:Modulus math.

The modulus operator uses this basic syntax: Basic Syntax:

a mod b

Example:

For example, checking if a Department's employee count is even: Using the Department Class with an EmployeeCount attribute

self.EmployeeCount mod 2 = 0

This returns true if the employee count is even

You can also use modulus with collections: Using Modulus with a Department Collection

Department.allInstances
  ->select(d | d.EmployeeCount mod 2 = 1)

Results:

Related integer division

If you need the integer quotient rather than a remainder, use Integer::div. For example, integer division determines how many complete groups a value contains, while IEEERemainder evaluates the IEEE remainder after division.

See also