I would like to truncate every digit after the first non zero digit in the binary representation of an integer. I also need this to be as simple as possible (no function or multiple lines of code).
In example:
// in c++
int int1=7,int2=12,int3=34; //needs to work for any number
using some sort of operator (maybe bitwise combination?), I need these to give the following values
int1 -> 4
int2 -> 8
int3 -> 32
Truncating in binary was the only thing I could think of, so I am open to any ideas.
Thanks!