hey,today someone asked me one question in my class that what is the fastest way to multiply a number by 7 ?
I said yes you can use bit-wise operators. the code which i gave him is :
int n=10; // for example n = (n<<3)-n;
then he aksed me one more question :
n = (n<<2 + n<<1 + n);
now, which one is faster ? first one or second ? I was confused in this.
Then , I asked somebody else about this, he said the following code is fastest.
int n=10; // for example n = n*7;
Then , it confused me badly, Can you help me out ? Which one is faster and why ? I am not able to get this thing that who is right and which code (out of 1 and 2 ) is faster? And is the 3rd code fastest ? Thanks in advance.