# Operator precedence for: 1/-2/3

1. Feb 9, 2012

### Twinbee

The sum below has two potential answers:

A: 1/-2/3 = -0.1666666667
B: 1/-2/3 = -1.5

Programming languages and most (but not all) calculators claim A is correct.

However, B seems to follow operator precedence more accurately as the division is performed before the unary minus. Using brackets:

1/(-(2/3))
...makes more sense than:
(1/-2)/3

Is there a more official stance on the issue?

2. Feb 9, 2012

### Hurkyl

Staff Emeritus
That sounds backwards to me.

3. Feb 9, 2012

### AlephZero

If "division is performed before unary minus", what does 1/-2 mean?

4. Feb 9, 2012

### Twinbee

Okay, most people would agree that:

-3^2 = -9

So there the exponential operator has precedence over the unary minus. If ^ has precedence, it makes sense to reason that / and * should have precedence too.

The ordering of the symbols fundamentally disallows the / to be performed first here.

Last edited: Feb 9, 2012
5. Feb 9, 2012

### DrewD

The order of the unitary minus has nothing to do with it. The unitary minus is equivalent to multiplying by -1. The question is which division is performed first and the convention is to use some D*** parentheses!
When there is no good reason to assume someone can figure out what you mean, don't assume someone can figure out what you mean, just say it. However, if you have a gun to you head and are asked which one is right, I'd say "A" since it reads left to right and there is no convention in math (maybe there is in compsci where the computer doesn't have an option to think about it).

6. Feb 10, 2012

### Staff: Mentor

But the ^ operator is different from the arithmetic operators +, -, *, and /, and has higher precedence. For that reason, 3^2 + 2 is evaluated as 9 + 2 = 11, rather than 3^(2+2) = 81. Similarly 2 * 3^2 = 2 * 9 = 18, not 6^2 = 36.

7. Feb 10, 2012