Code example for BigInteger

Methods: bitLengthintValue

0
     * Create a prime number of 2 bits length. 
     */ 
    public void testConstructorPrime2() { 
        int bitLen = 2;
        Random rnd = new Random();
        BigInteger aNumber = new BigInteger(bitLen, 80, rnd);
        assertTrue("incorrect bitLength", aNumber.bitLength() == bitLen);
        int num = aNumber.intValue();
        assertTrue("incorrect value", num == 2 || num == 3);
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE