int main()
{
int i=3;
(i << 1);
cout << i; //Prints 3
}
I expected to get 6 because of shifting left one bit. Why does it not work?
You're not assigning the value of the expression (i << 1);
back to i
.
Try:
i = i << 1;
Or (same):
i <<= 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With