Order of operators

Mark Schonewille m.schonewille at economy-x-talk.com
Thu Aug 27 10:18:24 EDT 2009


Hi Jim,

This is about a calculation with potentially hundreds of parameters. I  
don't think that parsing the formula to reduce the number of brackets  
will be fast enough to make the exercise worthwhile.

I'm building up the formula in a repeat loop, one operator at a time:

1
1*2
1*2+3
etc.

I can leave brackets out when a + or - is added, but I wish I could  
leave them all out. I assume a calculation without brackets is faster,  
because the symbols between brackets are parsed first.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com

Download Snapper Screen Recorder at http://snapper.economy-x-talk.com

On 27 aug 2009, at 15:55, Jim Bufalini wrote:

> Not sure about no brackets without multiple puts into vars (which  
> should add
> time), but for less brackets:
>
> put ((1*2+3-4)/5)^6
>
> Answer is the same due to brackets, precedence of operators (*  
> before +) and
> left to right calculation (+ before -).
>
> But, I'm curious. How much time do brackets add? It's something I  
> never
> thought of.
>
> Aloha from Hawaii,
>
> Jim Bufalini




More information about the Use-livecode mailing list