Question #1
In Java, is shifting multiple times more expensive than using a single statement to shift the by the same number?
For example, is
int x = 5;
x = x << 16;
Faster than
int x = 5;
for (int i=0; i<16; ++i) {
x = x << 1;
}
Further, what about
int x = 5;
for (int i=0; i<16; ++i) {
x = x*2;
}
Edit: What is the precise performance of "x << 16"? Is it the same speed as "x << 1"?
Question #2
Is there a resource online that I can utilize to determine various bitwise operation performances in Java, so that I do not have to waste the time of StackOverflow users? :-)