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.

Arithmetic expressions

Last modified: December 5, 2023

A number of arithmetic expressions are supported, all of which work on numeric types (Integer/Long, Float and Decimal).

Multiplication

Multiplies two numbers.

Input parameters

  • First number Type: Integer/Long, Float or Decimal
  • Second number Type: Integer/Long, Float or Decimal

Output

If the two inputs are both of type Integer/Long, the result is of type Integer/Long.

If any of the two inputs is of type Decimal, the result is of type Decimal.

if any of the two inputs is of type Float and they’re both not of type Decimal, the result is of type Float.

1
3 * 4

results in

1
12

Division

Divides two numbers. You can use either the div or colon ( : ) syntax, as can be seen below in the examples. The colon ( : ) syntax is inspired by the divide symbol ÷. We cannot use the more conventional slash ( / ) syntax because that would conflict with the slash used for separating objects and members.

Input parameters

  • First number Type: Integer/Long, Float or Decimal
  • Second number Type: Integer/Long, Float or Decimal

Output

If any of the two inputs is of type Decimal, the result is of type Decimal. Otherwise the result is of type Float.

“div” syntax:

1
3 div 5

results in

1
0.6

“:” syntax:

1
12 : 3

results in

1
4.0

Modulo

Calculates the remainder of the division of one number by another. In other words, m modulo n corresponds to: m = p + k*n, where p is the result of the operation m modulo n.

Input parameters

  • First number Type: Integer/Long, Float or Decimal
  • Second number Type: Integer/Long, Float or Decimal

Output

If the two inputs are both of type Integer/Long, the result is of type Integer/Long.

If any of the two inputs is of type Decimal, the result is of type Decimal.

if any of the two inputs is of type Float and they’re both not of type Decimal, the result is of type Float.

1
23 mod 5

results in an Integer/Long with value

1
3

Alternatively,

1
23 mod 5.6

results in a Float with value

1
0.6

Addition

Adds two numbers.

Input parameters

  • First number Type: Integer/Long, Float or Decimal
  • Second number Type: Integer/Long, Float or Decimal

Output

If the two inputs are both of type Integer/Long, the result is of type Integer/Long.

If any of the two inputs is of type Decimal, the result is of type Decimal.

if any of the two inputs is of type Float and they’re both not of type Decimal, the result is of type Float.

1
-3 + 4

results in an Integer/Long with value

1
1
1
4.5 + 3

results in a Float with value

1
7.5

Subtraction

Subtracts the second input from the first.

Input parameters

  • First number Type: Integer/Long, Float or Decimal
  • Second number Type: Integer/Long, Float or Decimal

Output

If the two inputs are both of type Integer/Long, the result is of type Integer/Long.

If any of the two inputs is of type Decimal, the result is of type Decimal.

if any of the two inputs is of type Float and they’re both not of type Decimal, the result is of type Float.

1
5 - 4

results in an Integer/Long with value

1
1
1
34.4 - 3.1

results in a Float with value

1
31.3