## Posts Tagged bitwise

Tags: , , ,

There are so many kinds of numbers we deal with on a regular basis and the C++ Standard Library has a full suite of tools to deal with them. Today we’ll look into random numbers, ratios, mathematical constants, bit manipulation, complex numbers, and more!

2 Comments

Tags: , ,

Today we continue to explore how we can store values in less than a byte. We’ll expand the `BitStream` struct with the capability to write values in addition to just reading them. Read on to see how to implement this functionality and for the full source code which you can use in your projects.

2 Comments

Tags: , ,

The smallest a C# type can be is one byte. The `byte` type and and an empty struct are examples of this. But what if we want to store data in less than a byte to improve performance such as load times and CPU cache utilization? Today’s article does just this by packing at the bit level!

2 Comments

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.

14 Comments

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!

14 Comments

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!

15 Comments

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.

25 Comments