Java 8 BigInteger - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BigInteger class.

This code example shows how to use the following methods: intValue, toByteArray
public class RoundTripTest 
{ 
    @Test 
    public void testInteger() 
    { 
        BigInteger bi = new BigInteger("1");
        assert bi.intValue() == 1;
        assert IntegerType.instance.getString(IntegerType.instance.fromString("1")).equals("1"); 
        assert IntegerType.instance.fromString(IntegerType.instance.getString(ByteBuffer.wrap(bi.toByteArray())))
                .equals(ByteBuffer.wrap(bi.toByteArray()));
        assert IntegerType.instance.compose(ByteBuffer.wrap(bi.toByteArray())).equals(bi);
        assert IntegerSerializer.instance.toString(bi).equals("1");
    } 
 
    @Test 
    public void testLong() 
    { 
        byte[] v = new byte[]{0,0,0,0,0,0,0,1};
        assert LongType.instance.getString(LongType.instance.fromString("1")).equals("1"); 
        assert LongType.instance.fromString(LongType.instance.getString(ByteBuffer.wrap(v)))
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add, subtract
    } 
 
    private static void invalidateIntRange(ModelTypeValidator testee) {
        assertInvalid(testee, new ModelNode().set(BigDecimal.valueOf(Integer.MAX_VALUE).add(BigDecimal.ONE)));
        assertInvalid(testee, new ModelNode().set(BigDecimal.valueOf(Integer.MIN_VALUE).subtract(BigDecimal.ONE)));
        assertInvalid(testee, new ModelNode().set(BigInteger.valueOf(Integer.MAX_VALUE).add(BigInteger.ONE)));
        assertInvalid(testee, new ModelNode().set(BigInteger.valueOf(Integer.MIN_VALUE).subtract(BigInteger.ONE)));
        assertInvalid(testee, new ModelNode().set(Integer.MAX_VALUE + 1L));
        assertInvalid(testee, new ModelNode().set(Integer.MIN_VALUE - 1L));
        assertInvalid(testee, new ModelNode().set(Integer.MAX_VALUE + 1d));
        assertInvalid(testee, new ModelNode().set(Integer.MIN_VALUE - 1d));
    } 
 
    private static void invalidateLongRange(ModelTypeValidator testee) {
        assertInvalid(testee, new ModelNode().set(BigDecimal.valueOf(Long.MAX_VALUE).add(BigDecimal.ONE)));
        assertInvalid(testee, new ModelNode().set(BigDecimal.valueOf(Long.MIN_VALUE).subtract(BigDecimal.ONE)));
        assertInvalid(testee, new ModelNode().set(BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE)));
        assertInvalid(testee, new ModelNode().set(BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE)));
        assertInvalid(testee, new ModelNode().set(Long.MAX_VALUE * 10d));
        assertInvalid(testee, new ModelNode().set(Long.MIN_VALUE * 10d));
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 
        BigInteger integerType;
 
        try 
        { 
            integerType = new BigInteger(source);
        } 
        catch (Exception e)
        { 
            throw new MarshalException(String.format("unable to make int from '%s'", source), e);
        } 
 
        return decompose(integerType);
    } 
 
    public CQL3Type asCQL3Type() 
    { 
        return CQL3Type.Native.VARINT; 
    } 
 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: bitLength, mod
        ECPublicKeyParameters   Q2U,
        ECPublicKeyParameters   Q1V,
        ECPublicKeyParameters   Q2V)
    { 
        BigInteger n = parameters.getN();
        int e = (n.bitLength() + 1) / 2;
        BigInteger powE = ECConstants.ONE.shiftLeft(e);
 
        // The Q2U public key is optional 
        ECPoint q;
        if (Q2U == null)
        { 
            q = parameters.getG().multiply(d2U.getD());
        } 
        else 
        { 
            q = Q2U.getQ();
        } 
 
        BigInteger x = q.getX().toBigInteger();

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: compareTo, modInverse
        BigInteger      k;
        int                  qBitLength = params.getQ().bitLength();
 
        do  
        { 
            k = new BigInteger(qBitLength, random);
        } 
        while (k.compareTo(params.getQ()) >= 0);
 
        BigInteger  r = params.getG().modPow(k, params.getP()).mod(params.getQ());
 
        k = k.modInverse(params.getQ()).multiply(
                    m.add(((DSAPrivateKeyParameters)key).getX().multiply(r)));
 
        BigInteger  s = k.mod(params.getQ());
 
        BigInteger[]  res = new BigInteger[2];
 
        res[0] = r;
        res[1] = s;
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 BigInteger Questions & Answers:

See Code Examples for Java 8 BigInteger Methods: