Java BigInteger Calculate getRandomBigInteger(int bits)

Here you can find the source of getRandomBigInteger(int bits)

Description

Creates a random BigInteger greater than 0 with the specified number of bits.

License

Apache License

Parameter

Parameter Description
bits number of bits to generate

Return

random BigInteger

Declaration

public static BigInteger getRandomBigInteger(int bits) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

import java.util.Random;

public class Main {
    /**//from  w  w w . java2 s.  c o  m
     * Creates a random BigInteger greater than 0 with the specified number of bits.
     *
     * @param bits number of bits to generate
     * @return random BigInteger
     */
    public static BigInteger getRandomBigInteger(int bits) {
        return new BigInteger(bits, new Random());
    }
}

Related

  1. getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)
  2. getPrivateKey(BigInteger ran, BigInteger publicKey)
  3. getPrivateKeyBytes(BigInteger privateKey)
  4. getQosFlowId(short tableId, BigInteger dpId, int lportTag)
  5. getRadixNumberInString(BigInteger integerNumber, int radix)
  6. getRandomInteger(BigInteger n, Random rand)
  7. getSize(BigInteger number)
  8. getValueWithUnit(BigInteger value, final int places)
  9. getVersionString(BigInteger versionNumber)