src/main/java/org/apache/hadoop/hdfs/server/namenode/SRandom.java
long nextLong(long bound) {
    // error checking and 2^x checking removed for simplicity.
    long bits;
    long val;
    do {
      bits = (nextLong() << 1) >>> 1;
      val = bits % bound;
    } while (bits - val + (bound - 1) < 0L);
    return val;
  }
/** Returns a long that is bounded between 0 and @param bound. */
Returns a long that is bounded between 0 and @param bound.
Returns a long that is bounded between 0 and @param bound .
long nextLong(long bound) {
    long bits;
    long val;
    do {
      bits = (nextLong() << 1) >>> 1;
      val = bits % bound;
    } while (bits - val + (bound - 1) < 0L);
    return val;
  }
long nextLong ( long bound ) { long bits ; long val ; do { bits = ( nextLong ( ) << 1 ) >>> 1 ; val = bits % bound ; } while ( bits - val + ( bound - 1 ) < 0L ) ; return val ; }
Returns a long that is bounded between 0 and @param bound.
Returns a long that is bounded between 0 and @param bound .
// error checking and 2^x checking removed for simplicity.