I have a task to do. If I have some some int variable and If I apply left shift operator on that, it adds "0" on left side of value.
view plaincopy to clipboardprint?
byte a = 5, b;
i = a << 2;
So, it will work like this, 5 as binary : 0101 1st time left shift: 01010 2nd time left shift: 010100
So, the answer will be 20.
But, I want to have "1" instead of "0"s. So, it should have something like this..:
5 as binary : 0101 1st time left shift: 01011 2nd time left shift: 010111
So, the value should be 23.
How do I do this in java. Please help me asap.
Thanks. Code Eater.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.