Advanced Arithmetic Operations on Integers
Explore advanced arithmetic operations on integers in D programming including negation, post-increment, post-decrement, and operator precedence. Understand how to combine operators effectively and write clear expressions using parentheses to ensure correct results and intent.
We'll cover the following...
We'll cover the following...
Arithmetic operations with assignment
All of the operators that take two expressions have assignment counterparts. These operators assign the result back to the expression that is on the left-hand side:
Negation: -
This operator converts the value of the expression from negative to positive or vice versa:
It is different from subtraction because it takes only one operand. Since unsigned types cannot have negative values, the result of using this operator with unsigned types can be surprising:
The type of -number ...