2010.12.08

Using integers to store multiple boolean values

Before starting I have to say that I come from a design background and not so long ago I didn’t know anything about bitwise operations, in fact I didn’t even know that it existed, the content described on this post should be trivial for developers coming from a computer science background or low-level languages…

The intention of this post is not to teach what each bitwise operator does, in fact I’m going to explain how to use it without telling what it does since I think it may be easier to understand. The main reason for writing this post is because I had to explain this technique to a couple of different friends over the past years (or at least I tried…) and also because I believe that most front-end developers don’t know about it.

I think I’ve learned it around 3 years ago when I was planing to code a multiplayer RPG game with a couple of friends and was doing some research about ways to optimize data transfer, that was probably the first time I saw a real use for bitwise operations on high-level programing besides splitting color channels…
Read more…