Here you can find the source of bitLength(int num)
public static int bitLength(int num)
//package com.java2s; //License from project: BSD License public class Main { public static int bitLength(int num) { return (int) Math.ceil(Math.log((double) num) / Math.log(2)); }// w ww .j ava2s .co m }