Prev | Current Page 133 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Binary Operators
Binary operators are so named because they operate on two values. They include the addition operator
( + ) for adding values together, the subtraction operator ( - ) for subtracting one value from another, the
forward slash operator ( / ) for dividing one value by another, the asterisk operator ( * ) for multiplying
two values, the modulo operator ( % ) for finding the remaining value of a division and the equals operator
( = ), which is otherwise known as the assignment operator, and is used to assign values to variables.
These are the core operators that you should know well, regardless of your programming background.
Operator Precedence
When performing regular arithmetic with literal or variable data, it is important to bear in mind the
order of operator precedence. For example, if you were to try to execute the following arithmetic, what
result would you get?
var result:Float = 10 * 2 + 1;
Without understanding the order or operator precedence, you may multiply the 10 by 2, which would be
20, then add the one, making 21.


Pages:
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145