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.

The table below shows whether casting and conversion are supported.
  • -- : No, casting and conversion are not supported
  • Y : Yes, casting and conversion are supported
  DateTime Date Time of Day Integer Decimal Double True or False Other (text)
                 
DateTime -- -- -- -- -- -- -- --
Date -- -- -- -- -- -- -- --
Time of Day -- -- -- -- -- -- -- --
Integer -- -- -- Y Y Y -- --
Decimal -- -- -- Y Y Y -- --
Double -- -- -- Y Y Y -- --
TrueFalse -- -- -- -- -- -- -- --
Other (text) -- -- -- -- -- -- -- --

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