Math.abs is a commonly-used utility function for taking the absolute value of a
Number. However, there’s no special-case version for taking the absolute value of an
int. Of course
Math.abs will work for
int values, but we can do it faster. Read on for a couple of ways.
Posts Tagged math
The site has had many articles about improving the performance of your app, but never discussed the basic methodology on which all optimizations should be based. Today’s article will go over a scientific approach to optimizing that makes use of a tool known as a profiler and demonstrate using an AS3 application just why it’s so important to usage such a tool.
Vector3D class debuted in Flash Player 10.0 as Adobe’s official implementation of, well, a 3D mathematical vector (not the pseudo-
Vector). Weirdly, it has a
w component and is therefore technically a 4D vector, but its API inconsistently make use of the fourth dimension. There are also strange oversights, inefficiencies, and functionality it really should have always had. Read on for my custom
Vector3DExt—that fixes all of these problems by extending and improving on the original.
I’ve been looking at a lot of AVM2 bytecode recently with the excellent Nemo440 AIR app. Some of the code was using my inline Math.ceil() function and I noticed that the int() cast is implemented like any other function call. Today’s article will show you how to optimize the inline Math.ceil() call even further by avoiding this function call.
Math.ceil() is a common, mundane function that you likely call all the time. I know I do. If performance gets to be important and you have a Math.ceil() in some inner loop or frequently called function, consider inlining it. Below I’ll show you how and provide a test app showing you just how much CPU time you’ll save.