18.4.6 Multiplying operators
Multiplying operators perform multiplication (*), division (/), and remainder calculation (%).
- Organization of this subsection
(1) Format
- Multiplicative expression
expression * expression
- Divisional expression
expression / expression
- Remainder calculation expression
expression % expression
(2) Description
Multiplying operators perform normal arithmetic conversion for operands, according to the data type. Both of the operands must have numeric values. If one or both of the operands are of the string type, this results in an error.
-
The multiplication operator (*) multiplies two operands. The operands may be integer or float type.
-
The division operator (/) divides the first operand by the second operand. The operands may be integer or float type. The data types of both operands may be different. While the result of division by 0 is undefined, the error message is displayed upon a syntax check or during runtime. If both of the operands are positive or unsigned, the result is rounded off to the nearest integer.
-
The operands subject to the remainder calculation operator (%) must have integers. The result of the calculation provides the remainder with the first operand divided by the second operand. If the calculation is indivisible, the result is determined according to the following rules:
-
If the right operand is 0, the result is undefined.
-
If both of the operands are positive or unsigned, the result is positive.
-
(3) Example of coding
MAIN { if (sloop_cnt > 10) AIT_Sleep(SLEEP_TIME / 2); else AIT_Sleep(SLEEP_TIME * 2); endif; }
(4) Notes
-
The conversion provided by multiplying operators does not handle overflow and underflow. If the result of conversion by a multiplying operator cannot be represented with the data type of the operand, information may be lost.
-
If the operand is divided by 0 during runtime, control moves to the ERROR section.