I am a c++ programmer and occasionally I'll come across some code that is using bitwise operators to manipulate things at the bit level, but I have no real understanding of those concepts. So I would like a resource to help me learn it so well that it becomes second nature. Does anyone know of good resources for this? A google search did not provide me much useful information. Maybe I'm not sure what to look for. Thanks!
Bit manipulation, in some cases, can obviate or reduce the need to loop over a data structure and can give many-fold speed-ups, as bit manipulations are processed in parallel, but the code can become more difficult to write and maintain.
Playing with bits can be fun with competitive programming. The bits work faster by reducing your execution time as it is the greatest factor in competitive programming. Faster the execution time better the code performance. So, let's know about the major hacks that can be done at a bit level to optimise the code.
For most other tasks, modern programming languages allow the programmer to work directly with abstractions instead of bits representing those abstractions. Bit manipulation can obviate or reduce the need to loop over a data structure and can speed up coding as bit manipulations are processed in parallel.
I absolutely love Henry Warren's Hacker's Delight book. The website for it offers Chapter 2 ("Basics") as a free sample which, despite the name, offers some fairly sophisticated bit manipulation tricks. It might not be the best place to start, but it's fantastic once you start to get comfortable with bit arithmetic.
You'll have to know the background of the binary system. http://en.wikipedia.org/wiki/Binary_numeral_system has a great overview. Look at http://en.wikipedia.org/wiki/Bitwise_operation for bitwise operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With