Here you can find the source of countBitsNeeded(int value)
Parameter | Description |
---|---|
value | unsigned 32 bit int value |
public final static int countBitsNeeded(int value)
//package com.java2s; public class Main { /**//from ww w . j ava2 s . co m * Find out number of bits needed to represent a positive integer * * @param value unsigned 32 bit int value * @return number of bits needed to store a value */ public final static int countBitsNeeded(int value) { return Integer.SIZE - Integer.numberOfLeadingZeros(value); } }