E
Elijah Bailey
I have a long x;
I want to write a function
long f(long x, int k)
such that it extracts every k-th bit of x, concatenates
them and returns it. Anyone can help me in writing this
function?
examples
x = 10101010 k = 1 f(x) = 10101010
x = 10101010 k = 2 f(x) = 1111
x = 10101010 k = 3 f(x) = 010
x = 10101010 k = 4 f(x) = 11
Any bit gurus here who can help me?
Thanks,
--Elijah
I want to write a function
long f(long x, int k)
such that it extracts every k-th bit of x, concatenates
them and returns it. Anyone can help me in writing this
function?
examples
x = 10101010 k = 1 f(x) = 10101010
x = 10101010 k = 2 f(x) = 1111
x = 10101010 k = 3 f(x) = 010
x = 10101010 k = 4 f(x) = 11
Any bit gurus here who can help me?
Thanks,
--Elijah