Reputation: 909
I have the below equation.
A=B<<1.
Could some one please tell me how I can get back B given A?
Upvotes: 1
Views: 1207
Reputation: 52538
You can't. The highest bit of B is lost, and there is no way you can get it back.
Upvotes: 1
Reputation: 2117
You can simply use the right shift operator:
B = A >> 1
Details see
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html
and this
Upvotes: 0