public static int simpleIntLog2 ( final int x ) { final int exp = Integer . numberOfTrailingZeros ( x ) ; if ( x != ( 1 << exp ) ) { throw new SketchesArgumentException ( "Argument x cannot be negative or zero." ) ; } return exp ; }
Gives the log2 of an integer that is known to be a power of 2 .