View Full Version : mathematical calculation order
sneeuwitje
06-05-2003, 11:17 AM
very small, but i NEED to know:
Anybody know why Flash doesn't follow regular calculation order:
multiply, divide, add /subtract ?
I thought
var myVar = x/y*z;
would normally be executed as:
x/(y*z)
but Flash does:
(x/y)*z
Funny || am i wrong?
farafiro
06-05-2003, 11:54 AM
not funny, it's right
flash executes the * and / before + and -
but if anoy of each group are together it goes ascending (as the order it's written in)
sneeuwitje
06-05-2003, 12:16 PM
am i wrong then?
Or what do we call this: a bug or an elephant?
And does anyone know more about what other "not funny stuff" this issue involves?
farafiro
06-05-2003, 12:21 PM
bug ???? huh
who said so, it's Math on PCs
sneeuwitje
06-05-2003, 12:52 PM
1. math on PCs is different from real math
2. i'm finding out why i never scored > C for maths in school
:eek:
magicwand
06-05-2003, 04:33 PM
var myVar = x/y*z;
is same as
var myVar = x/(y*z);
every computer(i think) follows same order we learned in school
:)
sneeuwitje
06-05-2003, 05:37 PM
try this in php
<?
echo "6/8*25=".(6/8*25)."<br>";
echo "(6/(8*25))=".(6/(8*25));
?>
it wil come up with:
6/8*25=18.75
(6/(8*25))=0.03
magicwand
06-05-2003, 05:43 PM
oops.......
sorry
i read them wrong
anyway
order of operation:
Inside the ( )
Multiplication and Division which ever comes first.(from your ex. div is first )
addition and subtraction whichever comes first.
sorry about wrong info.
sneeuwitje
06-05-2003, 08:34 PM
and at the very basics of it too ...
sorry if this thread annoyed any of you, but it cleared my thinking. I get this way sometimes; wanting to re-discover the wheel and so on - maybe it shouldn't be round at all ...? :D
But enough of this already. It's like farafiro posted in the 1st reply;
* and / are on the same level: which ever comes 1st goes 1st.
and the same for + and - (but that was never a question)
thread closed as far as i'm concerned.
senocular
06-05-2003, 08:53 PM
look in Flash Help; theres a whole page for this.
Macromedia/Flash MX/Help/Flash/html/23_appendix_b.html
or through Flash Help:
Using Flash > Operator Precedence and Associativity > Operator List
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.