This is probably pretty basic, but to save me an hour or so of grief can anyone tell me how you can work out the number of bits required to represent a given positive intege
This is in C, but I suspect you could convert to Java fairly easily:
Find the log base 2 of an N-bit integer in O(lg(N)) operations