What is the value of the expression 3/4 ?
0
Most of the operators we are interested in take two operands. In each of the following examples the operator has two operands:
34 + 12 | 19/3 | 90 - sum | val * x |
However, unary operators take just one operand:
+93 | -72 | +sum | -Math.PI |
A binary operator will always have exactly two operands. However, sometimes one or both operands of a binary operator is a subexpression.
A subexpression is a part of an expression that is by itself a correct expression.
Sometimes a subexpression is a constant, like "8". Any expression can be a subexpression of a larger expression. In the following, both operands of the red operator are subexpressions.
2*3 + 8 | (x - y) / 2.3 | (sum - 2) * (sum + 3) |
In an expression like 34.12 / 68.0
how do you know if the /
means
integer division or means floating point division ?