I am very new to Java (and programming in general, my previous experience is with ActionScript 2.0 and some simple JavaScript), and I am working my way slowly and methodically through Java: A Beginner’s Guide by Herbert Schildt. It is an incredible book.
For one thing, I finally understand more-or-less what bitwise operators (which I first encountered in ActionScript 2.0) do, and that they are more efficient than other methods for certain sums.
My question is, is it more efficient to use a method that uses, say, a shift right, to perform all your divisions/2 (or divisions/even) for you in a large program with many calculations (in this case, a sprawling RPG), or is it more efficient to simply use standard mathematical operations because the compiler will optimise it all for you?
Or, am I asking the wrong question entirely?
You are asking the wrong question entirely. The question you should be asking is “should I keep my code simple and readable, or use tricks that I believe will improve its performance, even though I haven’t measured its performance.” The answer should be obvious.
Bitwise operators have their place, especially when you’re dealing with binary file formats that need to pack a lot of data into small space. And it’s absolutely critical to know how to mask out the high bits of a byte so that you don’t accidentally sign-extend (print out these two variables to see what I mean):
But don’t go looking for places to use these operators, especially to replace such simple tasks as dividing by 2.