In my previous posts, I presented optimizations for e bunch of Maths functions, so lets continue and see whats next in the list ! Today I am going to explore ways to optimize Math.pow(2,x) or 2^x , as well as Math.exp One easy trick to fast perform 2^i for integers is to use bit shifting, […]

~ read more ~## Posts by

# reciprocal 1/x tricks **updated**

Can we fast compute 1.0/x ? static public function recriprocal( value:Number ):Number { return 1.0/value; } So here some ideas, we already have a fast way to compute 1/sqrt(x), if you look at 1/x and 1/sqrt(x) , you will notice that both equations are pretty close, so it gives us a pretty good “first guess”. […]

~ read more ~# AS3 vector v[int(i+1)] trick ?

When accessing a vector such as v:Vector.<int> , we often have to access by index i , i+1 etc. Few suggested this trick , force cast (i+1) to an int, and do v[int(i+1)]. Is that trick working ? Let’s find out ! First, lets create a really large Vector: var REPS:int = 300000; //number of […]

~ read more ~# Euclidean division

How to fast perform the euclidean division of two integers and compute the rest the of the division at the same time ? The naive approach is to simply get the result using the / and the % operator: q = i/j; r = i%j; As we know, modulo is very slow, so instead, we […]

~ read more ~# Fastest way to sort Numbers ?

Let’s beat the Array.sort for Numbers, lets beat the best as3 implementation of quicksort and lets beat about any AS3 sorting function you have seen so far. Here 2 really fast algorithms to sort floats (or Numbers), FlashSort and Radix ! FlashSort I presented in an earlier post a really fast flashSort implementation for Integers […]

~ read more ~
## Recent Comments