• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Order of operations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Subject: Re: Order of operations (From: Michael Cytrynowicz <email@hidden>)

  • Prev by Date: Re: TextEdit
  • Next by Date: Re: Order of operations (was: Eigenvalues &/or eigenvectors, anyone?)
  • Previous by thread: Subject: Re: Order of operations
  • Next by thread: Mount Volume
  • Index(es):
    • Date
    • Thread