I have the following question:
If asked whether to use a shift vs a multiply or divide for example the answer would be, let the JVM optimize.
Example here: is-shifting-bits-faster-than-multiplying
Now I was looking at the jdk source, for example Priority Queue and the code uses only shifting for both multiplication and division (signed and unsigned).
Taking for granted that the post in SO is the valid answer I was wondering why in jdk they prefer to do it by shifting?
Is it some subtle detail unrelated to performance? I am suspecting it must have something to do with over/underflow multiplication and division but I am not sure.
Anyone has an idea? Are subtly overflow issues handled better using shifting? Or it is just a matter of taste?