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!
I imagine there are other possibly better resources, but I remembered that there was an article on this I read a few years ago on GameDev.Net.
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.
I would suggest the following tutorials:
http://www.cprogramming.com/tutorial/bitwise_operators.html http://www.codeproject.com/KB/cpp/bitbashing.aspx
They both have nice examples.
Well, I guess every c/c++ book explains bitwise operators. There are also a lot of tutorials online.If I were you, I would improve my google skills. Delicious also has a good search functionality. Here are some of the links I have found:
http://www.gamedev.net/reference/articles/article1563.asp
http://www.vipan.com/htdocs/bitwisehelp.html
http://graphics.stanford.edu/~seander/bithacks.html
http://en.wikipedia.org/wiki/Bitwise_operation
http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
http://www.cprogramming.com/tutorial/bitwise_operators.html
http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/
http://www.codeproject.com/KB/cpp/bitbashing.aspx
http://www.eskimo.com/~scs/cclass/int/sx4ab.html
http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
http://www.somacon.com/p125.php
http://www.fredosaurus.com/notes-cpp/expressions/bitops.html
http://goanna.cs.rmit.edu.au/~stbird/Tutorials/BitwiseOps.html
http://www.custard.org/~andrew/programming/bitwise/
http://www.codeproject.com/KB/cpp/Bitwise_Operation.aspx
http://bits.stephan-brumme.com/
http://en.wikipedia.org/wiki/Bit_manipulation
http://www.hackersdelight.org/HDcode.htm
http://www.arduino.cc/playground/Code/BitMath
http://irc.essex.ac.uk/www.iota-six.co.uk/c/e4_bitwise_operators_and_or_xor.asp
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.
I agree with the responses above on that GameDev.net article. That was a good one for me in the past.
This article on Denormalization with Bitmasks (http://maggienelson.com/2009/02/denormalization-with-bitmasks/) was useful to me as well and includes database-specific examples, in case those are of use.