Skip to main content

All Questions

83 votes
7 answers
17k views

Why are bit masks called "masks" and what purpose do they serve?

Why are "bit masks" called like this? I know that they are mainly used for bitwise operations and the usage of bit masks is more efficient than the usage of separate variables. However my question ...
yoyo_fun's user avatar
  • 2,297
29 votes
11 answers
11k views

When I test out the difference in time between shifting and multiplying in C, there is no difference. Why?

I have been taught that shifting in binary is much more efficient than multiplying by 2^k. So I wanted to experiment, and I used the following code to test this out: #include <time.h> #include &...
NicholasFolk's user avatar