views:

163

answers:

4

I know the concepts of bit-wise operators, bit manipulation, 2's complement etc. But when it comes to solving something using bit manipulation it does not strike me. I takes me time to wrap my head around them.

I thought it would help if I looked at some questions regarding bit operators/bit manipulation but it left me even more confused as to how to approach this topic. I am not looking for an answer to a specific problem but a generalized approach / mindset while tackling bit manipulation. Thanks.

A: 

So what exactly are you looking for, this looks kind of vague to me to be honest. Have you ever read a book about for example C? You could look up some code examples on how to approach some standard programming solutions in C perhaps.

Younes
+1  A: 

I divine your question to be:

What approach should I take, and what mindset should I adopt, when tackling problems involving bit manipulation ?

If that is correct, read on, if not, stop now ...

Bit manipulation is a difficult topic for the beginner such as me. I will have to concentrate hard and pay careful attention as I work through a graded set of sample problems. I will revise what I learn at regular intervals.

High Performance Mark
+1  A: 

Answers given so far are nowhere near useful. But the link given by Naveen helped me a bit. Quite a lot of examples given here. I am trying to learn from them. Maybe it'll help others.

Bit Hacks

UPDATE: I have been going through the examples given in the link above. They were good. Also I stumbled on - Resource for Bitwise Programming link in SO. Excellent Resource. After going through all those resources I feel bitwise programming is easy! Never thought I would use that in a sentence :)

MovieYoda
Looks like your linked page was relocated. Forbidden. The site links to this: [http://graphics.stanford.edu/~seander/bithacks.html](http://graphics.stanford.edu/~seander/bithacks.html)
Jeff M
@Jeff. Yupp! Thanks. Updated the post too!
MovieYoda
A: 

I learned a lot about this by writing my own compact, cross-platform binary protocol for sending object messages over a stream (suck as a network socket).

Bart van Heukelom