Posts Tagged bitwise

Optimizing with Bit Twiddling Hacks

Tags: , ,

Stanford’s Sean Eron Anderson has a great page titled Bit Twiddling Hacks. This is a great resource for C programmers looking to employ bitwise operators (& | ^ ~ < < <<< >> >>> etc.) to speed up their code. But what about AS3 programmers? We have bitwise operators too, but will the same tricks work for us? Today’s article ports some of these bit twiddling hacks to AS3 and tests to see if any ground is gained.

Read the rest of this article »


Converting Numbers to Ints

Tags: , , , , , , ,

This is an extremely common task: converting a Number to an int. There are a lot of ways to do it, but which is fastest in AS3? Today we’ll look at a performance test app that attempts to find the fastest way to accomplish this. The answer just may surprise you!

Read the rest of this article »


Bitwise Alternatives to Multiply, Divide, and Modulus: Faster?

Tags: , , , , , ,

Many programmers are aware of a special case where you can use a bitwise shift for multiplication or division when you’re multiplying or dividing by a power of two. For example, you can replace i * 2 with i < < 1 and i / 2 with i >> 1. A lesser-known trick works for modulus. But are these alternatives actually any faster? Today’s article puts them to the test!

Read the rest of this article »


Faster Logic With Bitwise Operators

Tags: , , , , ,

Logical operators are necessary in every app, so it’s unfortunate that they are so slow in AS3. That’s why I was happy to see a potential alternative in a recent comment by Skyboy. Today’s article shows you how to do logic faster by avoiding logical operators (e.g. &&) and using their bitwise (e.g. &) operator counterparts instead.

Read the rest of this article »