I have a piece of code running into an loop, with a division by 100, which is reducing a little my fps count.
In majority of cases, is a int/uint type being divided by 100, resulting in a simple Number.
I just want to know any way to optimize that.
EDIT:
Little benchmark with the @scriptocalypse suggestion – multiplying for 0.01:
import flash.utils.getTimer;
for(var k:Number = 20; k > 0; k--)
{
var a:int = getTimer();
var o:Number = 100;
var p:Number;
for(var i:Number = 100000000; i > 0; i--)
{
p = o * 0.01; // took 423~510 <--------------
//p = o / 100; // took 713~768 <--------------
}
var b:int = getTimer();
trace( b - a);
}
I suspect that it’s not the division that’s causing the bulk of your issues, as even slow math operations should be relatively fast compared to other operations.
While this:
should theoretically be faster than
I still suspect that it won’t make much difference. What else are you doing in your loop?