Unary minus precedence preference
|
07-24-2014, 04:11 PM
Post: #27
|
|||
|
|||
RE: Unary minus precedence preference
I'll start by saying that I agree that -2^2 should be -4.
Now some philosophical thoughts. It seems to me that the problem is that we use "-" for at least 3 different operations:
The last one may require some explanation: I'm saying that in this case, the "-" is part of the number, not an operation. The same is true of the decimal mark: in "5.2", the "." isn't an operation, it's part of the way we specify the number itself. To see the difference, consider the following on a 50g: Code: X [ENTER] 5 [+/-] - ---> 'X--5' Or the strange case where sometimes numbers must be enclosed in parenthesis: 5 X Y^X [ENTER] -> '5^X' 5 [+/-] X Y^X [ENTER] ---> '(-5)^X' This means that decompiling symbolic expressions is hard: negative numbers decompile differently depending on the operations they're involved in. All of this would be easier of we used different symbols. Suppose:
Now nX^2 isn't a valid math expression. Neither is -X^2 since "-" is a binary operator. umX^2 is the original problem. This is NOT subtraction, so its precedence isn't specified by the PMDAS rules. Mathmatically, it would seem to come between Multiplication/Division and Addition/subtraction, so school children would be taught PMDUAS. What about 4-2^2 vs -2^2+4? In the new notation it's clear that you're using different operations here: 4-2^2, 4+n2^2 and 4+um2^2 are all different expressions (the latter simplifies to 4-2^2). |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)