The division operator is a slash (/). When using division, it is important to note whether the quotient is an integer, i.e. whether the dividend is a multiple of the divisor. If it is not, the remainder can be determined by means of a modulo operation (see section “Modulooperation” (Modulo operation )).
Rules:
The result is an integer (without remainder) in the range from -231 to +231-1.
The result of the division operation is calculated as follows:
If the quotient is an integer (i.e. there is no remainder), the quotient is inserted as the result.
If the quotient is not an integer (i.e. there is a remainder), the result is rounded down to the next number, which is provided with the sign yielded by the division operation.
Division by zero results in an error.
Example
Assignment | Result |
/A = 7 | |
/B = -4 | |
/C = A / B | -1 |
/D = A / 2 | 3 |
The division operation 7 : -4 returns the quotient -1.75. Since only an integer can be inserted as the result of a division operation, variable C is not rounded down to the next integer (-2); instead, it is rounded down from the unsigned amount, which is then provided with the sign yielded by the division operation: C = -1
The division operation 7 : 2 returns the quotient 3.5. Variable D is rounded down to the next integer, which is provided with the sign yielded by the division operation: D = 3.