Order of operations
Order of operations
- Subject: Order of operations
- From: Deivy Petrescu <email@hidden>
- Date: Fri, 9 May 2003 10:20:16 -0400
Go back to your high school days and simplify this:
y = (1-x)(1+x)-1
I get -x^2
Now, does that mean you get "the negative of x squared" or does it
mean you
get "the quantity minus x, squared"? Parentheses remove all ambiguity.
I was wrong.
My feeling is that x is a container and as such it has no sign. So, -x
is actually -1*x.
However, AS understands -x as it does -2, as an unary operation and
-x^2 = x^2. It is a matter of consistency, and I believe here computer
science takes precedence over math.
So I would make a distinction between -2^2 and -1*2^2, similarly I
would make a distinction between -1*x^2 and -x^2.
For most of the languages -x = -1*x. So unary and multiplication are at
the same level, while in AS unary takes precedence over power,
consistently. If the rules are clearly established before the game, the
game is fair.
Parenthesis is always good, since it eliminates all the ambiguity.
Regards
Deivy Petrescu
http://www.dicas.com/
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.