public long readBoundedLong(final long max) throws IOException {
    final int bits = 0 >= max ? 0 : (int) (Math.floor(Math.log(max) / Math.log(2)) + 1);
    return 0 < bits ? this.read(bits).toLong() : 0;
  }
public long readBoundedLong ( final long max ) throws IOException { final int bits = 0 >= max ? 0 : ( int ) ( Math . floor ( Math . log ( max ) / Math . log ( 2 ) ) + 1 ) ; return 0 < bits ? this . read ( bits ) . toLong ( ) : 0 ; }
Reads a single positive bounded integral value (up to 64-bit, including 0, excluding max)

@param max Maximum value (exclusive)
@return A long within the range [0, max)
@throws IOException the io exception