Package java.math

Examples of java.math.BigInteger.subtract()


        assertTrue(vol.hasSameValue(bigIntegerToTest));
        break;
    case TEST_HASH_CODE:
        int hc = vol.hashCode();
        ValueObjectBigInteger previous = new ValueObjectBigInteger(
          bigIntegerToTest.subtract(BigInteger.ONE));
        int hcPrevious = previous.hashCode();
        assertTrue(hc != hcPrevious);
        break;
    case TEST_IS_SAME_ENUM_TYPE:
        assertTrue(vol.isSameEnumType(ValueObjectEnum.BIGINTEGER));
View Full Code Here


    public static float getProgress(ByteSequence start, ByteSequence end, ByteSequence position) {
      int maxDepth = Math.min(Math.max(end.length(), start.length()), position.length());
      BigInteger startBI = new BigInteger(extractBytes(start, maxDepth));
      BigInteger endBI = new BigInteger(extractBytes(end, maxDepth));
      BigInteger positionBI = new BigInteger(extractBytes(position, maxDepth));
      return (float) (positionBI.subtract(startBI).doubleValue() / endBI.subtract(startBI).doubleValue());
    }
   
    public float getProgress(Key currentKey) {
      if (currentKey == null)
        return 0f;
View Full Code Here

   
    public static void main(String[] args) {
        BigInteger num = new BigInteger("10");
        num = num.pow(2000);
        num = num.multiply(new BigInteger("6"));
        num = num.subtract(new BigInteger("1"));
        System.out.println(num);
        System.out.println(num.isProbablePrime(Integer.MAX_VALUE));
    }
}
View Full Code Here

    {
        BigInteger firstAsBigInteger = new BigInteger(1, first.toByteArray());
        BigInteger lastAsBigInteger = new BigInteger(1, last.toByteArray());

        // note that first and last are included in the range.
        return lastAsBigInteger.subtract(firstAsBigInteger).add(BigInteger.ONE);
    }

    /**
     * Deaggregate a range of IPv6 addresses (which is not necessarily aligned with a single IPv6 network) into a minimal set of non
     * overlapping consecutive subnets.
View Full Code Here

        while (r.equals(ECConstants.ZERO));

        // generate s
        BigInteger x = privKey.getD();                // private key value
        BigInteger u = ((ECPrivateKeyParameters)tempPair.getPrivate()).getD();    // temp's private key value
        s = u.subtract(r.multiply(x)).mod(n);

        BigInteger[]  res = new BigInteger[2];
        res[0] = r;
        res[1] = s;
View Full Code Here

   
            // mQ = ((input mod q) ^ dQ)) mod q
            mQ = (input.remainder(q)).modPow(dQ, q);
   
            // h = qInv * (mP - mQ) mod p
            h = mP.subtract(mQ);
            h = h.multiply(qInv);
            h = h.mod(p);               // mod (in Java) returns the positive residual
   
            // m = h * q + mQ
            m = h.multiply(q);
View Full Code Here

        BigInteger startInt = convertIPv6AddressToBigInteger(start);
        BigInteger endInt = convertIPv6AddressToBigInteger(end);
        if (startInt.compareTo(endInt) > 0) {
            return null;
        }
        return endInt.subtract(startInt).add(BigInteger.ONE);
    }

    public static boolean isIp6InRange(String ip6, String ip6Range) {
        if (ip6Range == null) {
            return false;
View Full Code Here

  public static float getProgress(ByteSequence start, ByteSequence end, ByteSequence position) {
    int maxDepth = Math.min(Math.max(end.length(), start.length()), position.length());
    BigInteger startBI = new BigInteger(extractBytes(start, maxDepth));
    BigInteger endBI = new BigInteger(extractBytes(end, maxDepth));
    BigInteger positionBI = new BigInteger(extractBytes(position, maxDepth));
    return (float) (positionBI.subtract(startBI).doubleValue() / endBI.subtract(startBI).doubleValue());
  }

  public float getProgress(Key currentKey) {
    if (currentKey == null)
      return 0f;
View Full Code Here

   
    BigInteger bi = newPositiveBigInteger(er);
    if (bi.equals(BigInteger.ZERO))
      throw new IllegalArgumentException("Nothing comes before zero");
   
    bi = bi.subtract(BigInteger.ONE);
   
    byte ret[] = new byte[size];
    Arrays.fill(ret, (byte) 0xff);
   
    System.arraycopy(getBytes(bi, er.length), 0, ret, 0, er.length);
View Full Code Here

   
            // mQ = ((input mod q) ^ dQ)) mod q
            mQ = (input.remainder(q)).modPow(dQ, q);
   
            // h = qInv * (mP - mQ) mod p
            h = mP.subtract(mQ);
            h = h.multiply(qInv);
            h = h.mod(p);               // mod (in Java) returns the positive residual
   
            // m = h * q + mQ
            m = h.multiply(q);
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.