Conditions on binary representation of a number

45 Views Asked by At

I have a range of values from $1$ to $64$. I divide it into $4$ parts $1-16$, $17-32$, $33-48$, $49-64$ and i want to implement certain statements based on a number which lies in one of these four partitions. Now instead of these decimal representation of numbers i have the binary of these. So given an $x$ in binary how do i decide which partition it lies in? Or to be more precise what is the unique property of number that lies in say $1-16$ that distinguishes it from the other three partitions, and same way for the other partitions. Do i have to look at all the possible places there are $1$ in a numbers representation? Edit: For a number in the set $\{0,1,....2^l-1\}$ Hence the maximal number of bits required is $l$. If I want a number $x \leq \lfloor \frac{2^l-1}{2}\rfloor$ then i just ignore the most significant bit, is this reasoning correct?