2 + 4/2 + 1 --- 2 + 2 + 1 ------ 4 + 1 --------- 5
If you look in the
table of operators
you will see that the character -
is listed twice.
That is because -
is used for two purposes.
In some contexts, -
is the unary minus operator.
In other contexts, -
is the subtraction operator.
The unary minus is used to show a negative number. For example:
-97.34
means "negative ninety seven point thirty four." The subtraction operator is used to show a subtraction of one number from another. For example:
95 - 12
is an expression that calls for 12 to be subtracted from 95. The unary minus operator has high precedence. Addition and subtraction have low precedence. For example
-12 + 3
means add 3 to negative 12 (resulting in -9).
The unary plus +
can be applied to
a number to show that it is positive.
It also has high precidence.
It is rarely used.
What is the value of the following expression?
+24 + 3 * -4