3
int i=3;
int doubleThruShift = i<<1;
int doubleThruMul = i*2;

How fast is computing line 2 compared to computing line 3? Is the performance boost worth it , if we use left shift to multiply by 2?

user1422163
  • 145
  • 1
  • 9
  • 6
    JVM should detect and optimize such code, you should no worry. – Roman C Dec 27 '15 at 18:49
  • While I know what you meant, the code as shown should not take *any* time, you've only produced some constants that are not even used. – harold Dec 27 '15 at 18:53

0 Answers0