code: function generateRandom(bits, rng) {
    var num = new BigInteger(bits, rng);
    // force MSB set
    var bits1 = bits - 1;
    if(!num.testBit(bits1)) {
      num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
    }
    // align number on 30k+1 boundary
    num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
    return num;
  }
docs: Generates a random number using the given number of bits and RNG.
  
  @param bits the number of bits for the number.
  @param rng the random number generator to use.
  
  @return the random number.