# Order of operations or PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction.)

How can one be sure that the order of operations is being followed. Does AI look after that regardless of the programmer's text? or do i, as the coder, have to specify an order?
for example:
Does: d = √( l2 + w2)
equal:

Just curious

Charley

You have to set the order you want

Aside from that wierd max and min song and dance, yes.

(I think you turned the Cartesian Plane into a Boeing 737)

Why not use sqrt (((x1-x2)^2)+((y1-y2)^2))?

The AI2 block sockets act like parentheses () to force order of operations.

As long as you behave yourself and code values without side effects you should be safe.

I am working within the confines of a cartesian plane, yes.
Is it even possible to 'open the hood' and insert lines of code into AI?
I have done it all ways I could think, calculating the components and thence executing further calculations on the results. It does make sense that the order of blocks makes the difference. Measuring lengths and angles of lines drawn between multiple x,y coordinates can get tricky and am trying to simplify with single line formulas to save on coding and machine number crunching.

(I was testing [Max] [Min] blocks against [absolute] values to see if there was a difference. No stone overlooked, so to speak"

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.