Java log base 2

class TestJava {
	public static void main(String[] args) {
		int x = 20;
		int logBase2 = (int) (Math.log(x) / Math.log(2));
 
		System.out.println("Number: " + x);		
		System.out.println("Log Base 2: " + logBase2);		
	}
}

Output:

Number: 20
Log Base 2: 4
Content Protection by DMCA.com
Please Share