protected long nextLong(long n){
  Check.nonNegative(n);
  if (n <= Integer.MAX_VALUE) {
    return random.nextInt((int)n);
  }
 else {
    long bits;
    long val;
    do {
      bits=random.nextLong() & Long.MAX_VALUE;
      val=bits % n;
    }
 while (bits - val + (n - 1) < 0);
    return val;
  }
}

protected long nextLong ( long n ) { Check . nonNegative ( n ) ; if ( n <= Integer . MAX_VALUE ) { return random . nextInt ( ( int ) n ) ; } else { long bits ; long val ; do { bits = random . nextLong ( ) & Long . MAX_VALUE ; val = bits % n ; } while ( bits - val + ( n - 1 ) < 0 ) ; return val ; } }
returns a long in the range [ 0 , n ) .
