This table shows the valid combinations of types when the operator is *, / or %. To understand the calculation of the expression A * B, find the type of A in the Left Hand Side (rows) of each table. Find the type of B in the Right Hand Side (columns) if the table. Consult the numbered notes for the details of casting or conversion.
Right Hand Side
|
|
|
|
|
|
|
|
Other (text) |
Left Hand Side
|
||||||||
|
|
X |
X |
X |
X |
X |
X |
X |
X |
|
|
X |
X |
X |
X |
X |
X |
X |
X |
|
|
X |
X |
X |
X |
X |
X |
X |
X |
|
|
X |
X |
X |
1 |
1 |
1 |
X |
X |
|
|
X |
X |
X |
1 |
1 |
1 |
X |
X |
|
|
X |
X |
X |
1 |
1 |
1 |
X |
X |
|
|
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:
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.)@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 integerdown — round towards zerofloor — round to a more negative numberhalf_down — round to the nearest neighbor, where an equidistant value is rounded downhalf_even — round to the nearest neighbor, where an equidistant value is rounded to an even valuehalf_up — round to the nearest neighbor, where an equidistant value is rounded upunnecessary — assert that no rounding is necessaryup — round away from zero