mikeblas said:Like I said, the bitwise operators let you divide or multiply by powers of two. Certainly, you see the application of multiplcation and division, right? Maybe I'm not understanding what you're driving at.
I'm not explaining myself well, not your fault. A couple anecdotes and an example is about as close as I can get:
A few years ago I was messing around in Perl for fun, building a poker hand evaluator (Texas Hold 'Em, 7 cards, make the best 5 card hand and compare to another). My solution was tedious and slow. Then I saw a solution that someone else wrote, really fast and full of bitwise operators. I puzzled over it a few days and gave up. To this day I couldn't do the same thing.
More recently I was messing around with the GD graphics library (again in Perl) and wanted to make a circle. Not knowing much math I wound up calculating every point in a square, and if it was within the circle's radius (using the Pythagorean theorem to determine distance) it got colored in. I'm sure there's a faster way to do that.
The example would be AI. Say I have a hungry NPC in a roleplaying game (which is my ultimate goal) and that NPC doesn't have money, but does have a musical instrument and a weapon. Depending on the time of day, how hungry he is, where he is etc. he might choose to rob someone or play for coin. Rather than a ton of switch and if-else checks, along with scripting every behaviour of every NPC in the game, I think I can give NPCs a set of base attributes and let them go on their own. And I think bitwise operators are going to play a big part of that--but applying it is going to take a lot of plodding and planning on my part.
These are all just examples, not requests for specific help. What I'm trying to get to is a state of mind where I'll think "1011 & (0100 << 1)" is better to do than "if x > 7 && y >= 4 then"... See what I'm getting at? Sorry that I can't explain myself any more coherently than this.