Сумма величин i = j + 2;
Вычитание величин i = j - 3;
Изменение знака x = - x;
Умножение величин z = 3 * x;
Частное от деления i = j / 5;
Остаток от деления minutes = time % 60;
Добавление 1 к значению переменной i++;
Добавление 1 к значению переменной ++i;
Вычитание 1 от значения переменной k--;
Вычитание 1 от значения переменной --k;
Increment and decrement operations apply only to variables, they do not apply to constants. Prefix increment (++i) and decrement (--k) are applied to a variable just before that variable is used in an expression.
Postfix increments (i++) and decrements (k--) are applied to a variable immediately after that variable is used in an expression.
Ashes: Both lines have postfix increment. The result (y) is different. It turns out that it depends on the context of application...
Can you practically justify the expression x = x++; What do you want to say? Why not use an increment without a subsequent assignment of x++; As it is usually used.
Checked, the result is x=1, y=0
My bad, wrong result description!
My bad, wrong description of the results!
Key :
https://www.mql5.com/ru/docs/basis/operations/rules
The c++ standard does not define this place and explicitly says that it depends on the implementation. There are 2 main implementations:
1. Produce a postincrement immediately after the variable is used in the expression. (as we have done).
2. Postincrement after the whole expression is calculated.
Key :
https://www.mql5.com/ru/docs/basis/operations/rules
x=0; y=0; x = y++; // x = 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
Did the priority of the operations manage to change ?
x=0; y=0; x = y++; // x = 1 !
Completely confused!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
Perfectly correct in all postincrement implementations without exception.
If you walk the behaviour you seem to be expecting, use preincrement. x = ++y;
Completely confused!
x=0; y=0; x = y++; // x = 0 ? y= 1 !!!
x=0; y=0; y = y++; // y = 0 !!!
Section Arithmetic operations:
Increment and decrement operations apply only to variables, they do not apply to constants. Prefix increment (++i) and decrement (--k) are applied to a variable just before that variable is used in an expression.
Postfix increments (i++) and decrements (k--) are applied to a variable immediately after that variable is used in an expression.
Section Arithmetic operations:
...Postfix increments (i++) and decrements (k--) are applied to a variable immediately after that variable is used in an expression.
Both lines have postfix increment. The result (y) is different. It turns out that it depends on the context of application...