Here you can find the source of bits(int i)
Parameter | Description |
---|---|
i | source value |
public static int bits(int i)
//package com.java2s; /**/*ww w .j a v a 2s . c o m*/ * This code is released under the * Apache License Version 2.0 http://www.apache.org/licenses/. * * (c) Daniel Lemire, http://lemire.me/en/ */ public class Main { /** * Compute the integer logarithms (ceil(log(x+1)) of a value * * @param i * source value * @return integer logarithm */ public static int bits(int i) { return 32 - Integer.numberOfLeadingZeros(i); } }