This article is part of the series What you won’t learn in the basics courses and is aimed at people who have an understanding of programming, but want to gain a more deeper insight on how things work and why do they work that way.

Last time, we talked about character sets and encoding. This time, we will return to dealing with binary numbers. However, this time we won’t examine how binary numbers work and what is their nature. We have covered that in previous articles. Today, we will see how to apply that knowledge in practice by examining how bitwise¬†operations work.

This topic is usually neglected in a traditional computer science curriculum (At least it is in some universities I know). But I think that this knowledge can be useful for two reasons:

  1. Expanding your computer science knowledge by gaining a deeper understanding of binary numbers and of low-level computer science aspects.
  2. Gaining a valuable tool which can be useful when pursuing specialization as a low-level programmer (Embedded developer, for example).

We will start by examining what tools do we have at our disposal Рthe operations which modern programming languages provide us with. Then we will move on to applying that knowledge for actually manipulating numbers in a binary fashion and finally Рwe will see some real-world examples of how bitwise operations are used to achieve a highly efficient system.

Continue reading