|
4.3.3 int operations
-
++
changes its operand to its successor, is itself no int expression
-
--
changes its operand to its predecessor, is itself no int expression
-
+
addition
-
-
negation or subtraction
-
*
multiplication
-
/
integer division (omitting the remainder), rounding toward 0
-
div
integer division (omitting the remainder >= 0)
-
%
integer modulo (the remainder of the division / )
-
mod
integer modulo (the remainder of the division div ), always non-negative
-
^ , **
exponentiation (exponent must be non-negative)
-
< , > , <= , >= , == , <>
comparison
Note: An assignment j=i++; or j=i--; is not allowed,
in particular it does not change
the value of j , see Limitations.
Example:
| int i=1;
int j;
i++; i; i--; i;
→ 2
→ 1
// ++ and -- do not return a value as in C, can not assign
j = i++;
→ // ** right side is not a datum, assignment ignored
// the value of j is unchanged
j; i;
→ 0
→ 2
i+2, 2-i, 5^2;
→ 4 0 25
5 div 2, 8%3;
→ 2 2
-5 div 2, -5 / 2, -5 mod 2, -5 % 2;
→ -3 -2 1 -1
1<2, 2<=2;
→ 1 1
|
|