🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators Number::min ( r : Number ) : Number
This page was created by Peter on 2019-12-06. Last edited by Wikiadmin on 2026-07-29.

You can use Number::min(r : Number) : Number in OCL to return the lower of two numeric values; it is for expressions that must choose the smallest limit, value, or calculation result.

Syntax

self.min(r)
Part Meaning
self The first number: the value on which you call min.
r The second number to compare with self.
Return value The lowest of self and r, returned as a Number.

Number includes both Integer and Real values. See OCL Number Operators for the available numeric operations.

Examples

12.min(7)

The expression returns 7 because 7 is lower than 12.

(-3).min(4)

The expression returns -3 because -3 is lower than 4.

You can use min to cap a calculated value at an upper limit. In this example, the result cannot be greater than 100:

CalculatedValue.min(100)

If CalculatedValue is 125, the expression returns 100. If it is 80, the expression returns 80.

Related operators

Use min when you need the lower value. Use Number::max when you need the greater value instead.

For other common numeric transformations, see Number::abs, Number::round, and Number::floor.

See also