To determine the no. of leading 0's in an int
807605Sep 11 2007 — edited Sep 11 2007Hi,
I'm trying to determine the no. of leading 0's in an int.
I have something like:
int num = 000012345;
And for this i want the result to be 4.
Is there a way for me to achive this without actually converting my int into a String ? Pls advice.
Note:
I tried using Integer.numberOfLeadingZeros(). But i'm getting the result as 19. I think it is taking the number in octal and returning the leading 0 bits count. Not sure.
Also, i think in the firts place, the 0's in the number are not at all being stored. Is there a way so that i can force storage of leading 0's ?