A very common problem in programming is to calculate prime numbers fast.

There are a lot of interesting ways to solve this problem. I want to show you some solutions without the need for a complex algorithm. This type of solutions can also be applied to a lot of problems that may occur during your daily work. » more

Using right shifts, you can compute the next power of two of an 32-bit integer in a very effective way: » more

A programmer should often use assertions, so he is able to detect errors as soon as they occur.

In C++ the standard assert-macro doesn’t allow for an additional message. But with a simple workaround, you can print out additional information when the assertion occurs: » more

Sometimes it is required to flip the bytes of an integer. For example some image formats stores the chunks in ABGR format, so you have to flip them for use in OpenGL or Direct3D. » more

I recently got asked how to measure time in C++ in milliseconds. Surprise, surprise: It’s very easy: » more

In C/C++ you can define structs for your data. Sometimes it could be a little bit confusing how much memory they’ll allocate, if you don’t know what’s happening behind the scene. » more

This is not really a hack, but it’s fun anyway. » more

During game development you often need a variable that switches between two values with each call/loop/frame. » more

With the following for-loop you can decrement x until it reaches zero: » more

You often need conditions that reset variables during programming. » more