Advanced Online Calculator: Operator Precedence
Operator Precedence
The Alcula' Advanced Online Calculator performs the calculation after the full expression has been typed. The expression display shows the expression as it is being typed. After pressing the '=' key the calculator executes the calculation. It is therefore important to be aware of the order in which the calculations will be made to insure correct results. Parenthesis can be used to alter the preset order of operations.
Left to right
When operators have the same precedence, evaluation is made starting from the left side of the expression. For example, given an expression '5+6-4=': the calculator will first calculate '5+6=11', than '11-4=7'.
First: Unary operators
A unary operator is an operator that accepts only one operand. Unary operators have top priority and are calculated first.
Second: Multiplications & Divisions
Multiplications and divisions have equal precedence and are calculated after unary operators and before addition and subtraction
Third: Additions & Subtractions
Additions and subtractions also have equal precedence and are calculated after multiplications and divisions.
Using parenthesis
Parenthesis can be used to alter the natural order of precedence of the operators. They can be nested as long as the expression contains an equal number of open parenthesis and closed parenthesis. The '=' key will not execute the calculation if any open parenthesis has been left without a matching closed one.
Example: We want to calculate the expression 6+3+2 and multiply the result by 8. We cannot write 6+3+2x8= because multiplication has precedence over addition. If we did, first 2x8=16 would be evaluated and only afterwards: 6+3+16=25. So, to avoid the problem, we write (6+3+2)x8. Since the content within the parenthesis is calculated first, the calculator will perform the following evaluations: 6+3=9, 9+2=11, 11x8=88.