Basic operators
This section is a whirlwind tour of the basic operators D supports. For the most part, things are the same as they are in C. There are a few minor differences that will be highlighted as we come to them. More operators will appear later in this chapter and throughout the book. You can read more about D's operators at http://dlang.org/expression.html.
Arithmetic operators
All of the common
arithmetic operators are available: +
, -
, *
, /
and %
, representing addition, subtraction, multiplication, division, and modulus respectively. Additionally, D has an
exponentiation operator, ^^
, which raises the left operand to an exponent (power) represented by the right operand. For example, 22 can be expressed as 2 ^^ 2
.
D also supports the standard increment and decrement operators. In the prefix form (++x
and --x
), the result of the expression is the new value. In the postfix form (x++
and x--
), the result is the original value of the operand. To be more explicit, under the hood D is...