all groups > flash actionscript > august 2005 >
You're in the

flash actionscript

group:

Exponentiation in actionscript?



Exponentiation in actionscript? Vekdeer
8/8/2005 6:41:45 PM
flash actionscript: Hello,

This is my first post here, quick question. I am currently converting Perl
scripts into actionscipt. I have run into a * * (exponentiation operator). Is
there any such item in actionscript? the action script equivalent to the perl
script is below:

for (i=0; i<=8; i++){
intr = imn + (imx-imn)*i/8;
mi = intr / 1200;
temp = (1.0 / (1 + mi) ** tt); // this is the exponentiaton operator
if (temp < 1){
paymt = princ * mi / (1 - temp);
}
else{
paymt = princ / tt;
}
}
Re: Exponentiation in actionscript? FlashTastic
8/8/2005 7:13:36 PM
I think you want the Math.POW method of the Math class.

It works like so.

Math.POW(base,exponent)

so if you wanted say... x?, you would put Math.POW(x,2)

HTH
Re: Exponentiation in actionscript? Rothrock
8/8/2005 9:01:16 PM
Flash's Math capabilities aren't so great when compared with some other
languages. The exponent method is fairly slow, so in general x*x will be
quicker than Math.POW(x,2). So depending upon what you are doing you may want
to test it both ways and see which is quicker. (If such things matter.)

Since it looks like you are doing a mortgage calculator (or something similar)
I'm guessing the calculations won't be too taxing.
Re: Exponentiation in actionscript? Vekdeer
8/8/2005 9:20:54 PM
Great thank you,

I will go ahead and use the Math.pow. And yes... i am doing a mortgage calculator with a limit on the number of calculations so speed isnt a huge issue.

AddThis Social Bookmark Button