/**
 * fast integer log2 approximation.
 * @param n number to take log2 of, n >= 5.
 * @return 8 * (log2( n ) - 1 )
 */
public static int bitLog( int n )
   {
   if ( n <= 8 )
      {
      return 2 * n;
      }
   else
      {
      int b = 31;
      while ( b > 2 && n > 0 )
         {
         b--;
         n <<= 1;
         }
      n &= 0x70000000;
      n >>= 28;
      return n + 8 *( b - 1 );
      }
   } // end bitLog