Package java.math

Examples of java.math.BigInteger.intValue()


  /** start and end are BOTH inclusive */
  public static long nextLong(Random r, long start, long end) {
    assert end >= start;
    final BigInteger range = BigInteger.valueOf(end).add(BigInteger.valueOf(1)).subtract(BigInteger.valueOf(start));
    if (range.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) <= 0) {
      return start + r.nextInt(range.intValue());
    } else {
      // probably not evenly distributed when range is large, but OK for tests
      final BigInteger augend = new BigDecimal(range).multiply(new BigDecimal(r.nextDouble())).toBigInteger();
      final long result = BigInteger.valueOf(start).add(augend).longValue();
      assert result >= start;
View Full Code Here


        ASN1Sequence  seq)
    {
        Enumeration e = seq.getObjects();

        BigInteger  version = ((DERInteger)e.nextElement()).getValue();
        if (version.intValue() != 0)
        {
            throw new IllegalArgumentException("wrong version for private key info");
        }

        algId = new AlgorithmIdentifier((ASN1Sequence)e.nextElement());
View Full Code Here

        ASN1Sequence  seq)
    {
        Enumeration e = seq.getObjects();

        BigInteger  v = ((DERInteger)e.nextElement()).getValue();
        if (v.intValue() != 0 && v.intValue() != 1)
        {
            throw new IllegalArgumentException("wrong version for RSA private key");
        }

        version = v.intValue();
View Full Code Here

        ASN1Sequence  seq)
    {
        Enumeration e = seq.getObjects();

        BigInteger  v = ((DERInteger)e.nextElement()).getValue();
        if (v.intValue() != 0 && v.intValue() != 1)
        {
            throw new IllegalArgumentException("wrong version for RSA private key");
        }

        version = v.intValue();
View Full Code Here

        if (v.intValue() != 0 && v.intValue() != 1)
        {
            throw new IllegalArgumentException("wrong version for RSA private key");
        }

        version = v.intValue();
        modulus = ((DERInteger)e.nextElement()).getValue();
        publicExponent = ((DERInteger)e.nextElement()).getValue();
        privateExponent = ((DERInteger)e.nextElement()).getValue();
        prime1 = ((DERInteger)e.nextElement()).getValue();
        prime2 = ((DERInteger)e.nextElement()).getValue();
View Full Code Here

    }
   
    @Test
    public void testComboCount() {
      BigInteger combinationsCount = PermutationGenerator.getCombinationsCount(5, 3);
      assertEquals(10, combinationsCount.intValue());
      combinationsCount = PermutationGenerator.getCombinationsCount(7, 5);
      assertEquals(21, combinationsCount.intValue());
    }
}
View Full Code Here

    @Test
    public void testComboCount() {
      BigInteger combinationsCount = PermutationGenerator.getCombinationsCount(5, 3);
      assertEquals(10, combinationsCount.intValue());
      combinationsCount = PermutationGenerator.getCombinationsCount(7, 5);
      assertEquals(21, combinationsCount.intValue());
    }
}
View Full Code Here

                {
                    uLocal = (byte) uUnMod.subtract(pow2w).intValue();
                }
                else
                {
                    uLocal = (byte) uUnMod.intValue();
                }
                // uLocal is now in [-2^(width-1), 2^(width-1)-1]

                u[i] = uLocal;
                boolean s = true;
View Full Code Here

    }

    public static Literal makeInt(byte[] d) {
    BigInteger tmp = new BigInteger(d);
    return (d.length<=4)
      ? new Int(tmp.intValue())
      : new BigInt(tmp);
    }

    /** CodeInt is present in jump-table-by-arity (select_arity). */
    public static class CodeInt extends Operand {
View Full Code Here

      in.readFully(d);
      BigInteger value = new BigInteger(d);
      if (len>4 || value.compareTo(BigInteger.ZERO) < 0)
        throw new IOException("Code integer out of bounds: "+value);
      else
        return value.intValue();
    }
    }

  static class SectionMetadata {
    final int tag, offset, length;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.