Mendix 7 is no longer supported unless you have Extended Support (for details, please contact Mendix Support). Mendix 7 documentation will remain available for customers with Extended Support until July, 2024.

Mathematical function calls

Last modified: April 9, 2024

max

Returns the largest value from the specified arguments.

Input parameters

  • Two or more values that are all either of type Date and time or of a numeric type (Integer/Long, Float or Decimal).

Output

Returns the largest value from the specified arguments. If the arguments are of type Date and time, the result will also be of type Date and time. If the arguments are numeric, the result will be of the most precise type. For example, if both an Integer/Long and a Decimal argument are specified, the result will be of type Decimal.

Type: Integer/Long or Decimal

1
max(5, 1, 5, 6.7)

returns:

1
6.7

of type “Decimal”.

min

Returns the smallest value from the specified arguments.

Input

Two or more values that are all either of type Date and time or of a numeric type (Integer/Long, Float or Decimal).

Output

Returns the smallest value from the specified arguments. If the arguments are of type Date and time, the result will also be of type Date and time. If the arguments are numeric, the result will be of the most precise type. For example, if both an Integer/Long and a Decimal argument are specified, the result will be of type Decimal.

Type: Integer/Long or Decimal

1
min(5, 1, 5, 6.7)

returns:

1
1

of type “Decimal”

round

Rounds a number to a certain precision.

Input

  • a number Type: Integer/Long, Float or Decimal

  • a precision (optional) Type: Integer/Long

Output

In the Settings, your option for Round numbers can be set:

  • For the Half away from zero option (also called “commercial rounding”), +2.5 becomes +3 and -1.5 becomes -2
  • The Half to the nearest even number option (also called “bankers’ rounding”) is the default rounding mode used in IEEE 754 computing functions and operators; for example, +23.5 becomes +24, as does +24.5; and -22.5 becomes -22, as does -21.5

The second optional parameter determines the precision of the rounding. The default value is 0. The result will be of the most precise type possible. For a precision of 0, the result will be of integer/long type, and for all other precision values, the result will be of the decimal type.

Type: Integer/Long or Decimal

1
round(3.5)

returns:

1
4

of type “Integer/Long”

and

1
round(88.725,2)

returns:

1
88.72

of type Decimal

random

Generates a random number >= 0.0 and < 1.0

Output

A random number between 0.0 and 1.0 Type: Decimal

1
random()

floor

Rounds down to an integer (returns the largest integer which is less than or equal to the input).

Input

  • a number Type: Integer/Long, Float or Decimal

Output

The input value rounded down to the nearest integer.

Type: Integer/Long

1
floor(3.9)

returns:

1
3

and

1
floor(-1.2)

returns:

1
-2

ceil

Rounds up to an integer (returns the smallest integer which is greater than or equal to the input).

Input

  • a number Type: Integer/Long, Float or Decimal

Output

The input value rounded up to the nearest integer.

Type: Integer/Long

1
ceil(3.2)

returns:

1
4

and

1
ceil(-1.9)

returns:

1
-1

pow

Calculates the exponent of a number to a certain power.

Input

  • a number Type: Integer/Long, Float or Decimal
  • a power Type: Integer/Long, Float or Decimal

Output

The number to the power, as in, n^p.

Type: Decimal

1
pow(2, 3)

returns:

1
8

and

1
pow(2.5, 3)

returns:

1
15.625

Calculation of ‘pow’ with a decimal exponent might be less accurate, as the standard Java libraries do not support these calculations with high precision. Use a specialized library in a custom Java action if high precision is required for this case.

abs

Calculates the absolute value of a number (ie not negative).

Input

  • a number Type: Integer/Long, Float or Decimal

Output

The absolute value of the input, which is never negative. Corresponds to taking the square and then the square root.

Type: Integer/Long or Decimal

1
abs(-5)

and

1
abs(5)

both return:

1
5

floatsEqual

Compares the two numbers to decimal point p, which is equal to Precision.

Input

  • a number Type: Integer/Long or Float
  • another number Type: Integer/Long or Float
  • a precision Type: Integer/Long

Output

A value indicating whether the two numbers are equal given the specified precision.

Type: Boolean

1
floatsEqual(0.51, 0.50, 1)

returns:

1
true

and

1
floatsEqual(0.51, 0.50, 2)

returns:

1
false

currenciesEqual

See floatsEqual.