Multiply, divide, and remainder operations

This table shows the valid combinations of types when the operator is *, / or %. To understand the calculation of the expression A * B, find the intersection of the row for A's type and the column for B's type. Consult the numbered notes for the details of casting or conversion.

  DateTime Date Time of Day Integer Decimal Double True or False Other (text)
                 
DateTime X X X X X X X X
Date X X X X X X X X
Time of Day X X X X X X X X
Integer X X X 1 1 1 X X
Decimal X X X 1 1 1 X X
Double X X X 1 1 1 X X
TrueFalse X X X X X X X X
Other (text) X X X X X X X X

Notes for multiplication, division, and remainder operations:

  • Convert Integer > Double > BigDecimal until both operands have same type, then perform operation. The result is of the promoted type. (Conversion is directly to target type without performing additional intermediate conversions.)
  • Integer divide operations with the / operator provide no rounding. For example, 10/6 = 1. You can use the built-in function @divide (dividend, divisor, mode) with Integer or Decimal operations to compute a result that contains at least two decimal places and rounds half values up: @divide(10, 6) = 1.67. Rounding modes are the same as for the BigDecimal class:
    • ceiling — round to a more positive integer
    • down — round towards zero
    • floor — round to a more negative number
    • half_down — round to the nearest neighbor, where an equidistant value is rounded down
    • half_even — round to the nearest neighbor, where an equidistant value is rounded to an even value
    • half_up — round to the nearest neighbor, where an equidistant value is rounded up
    • unnecessary — assert that no rounding is necessary
    • up — round away from zero