Jesper de Jong wrote:That's not exactly right... the famous quote from prof. Knuth is: "premature optimization is the root of all evil". Not just optimization in general.
True. My slant on the old chestnut, but I stick by it.
Optimization (if needed) should almost always be a
design choice; not a coding one - and the choice of using bitwise ops is
definitely a coding one.
In thirty-plus years, I've yet to see a choice like that make a scrap of difference in overall performance; but I've seen LOTS of cases where it caused problems.
Case in point: the "XOR swap" - a wonderful bit of bitwise magic that is great as a teaching tool, but about as useful as a recursive factorial method when it comes to optimisation.
@Brian: We're arguing esoterics here (as we often do
). My advice to you: I think your instincts are right.
Learn how to do what you need to "the straightforward way" first.
Then, if you need to (or if it interests you), find out what bitwise ops can do. They ARE blisteringly fast; but they can also be very arcane.
Winston