How do you calculate log base 2 in Java for integers?

后端 未结 10 2133
情话喂你
情话喂你 2020-11-29 15:12

I use the following function to calculate log base 2 for integers:

public static int log2(int n){
    if(n <= 0) throw new IllegalArgumentException();
            


        
10条回答
提交回复
热议问题