Package java.math

Examples of java.math.BigInteger.subtract()


   
            // 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  x = new BigInteger(1, w);

                BigInteger  c = x.mod(q.multiply(TWO));

                p = x.subtract(c.subtract(ONE));

                if (p.testBit(size - 1))
                {
                    if (p.isProbablePrime(certainty))
                    {
View Full Code Here

      if (!p.isProbablePrime(param.getCertainty()))
      {
        continue;
      }
     
      if (e.gcd(p.subtract(ONE)).equals(ONE))
      {
        break;
      }
    }
View Full Code Here

            phi = p;
            p = q;
            q = phi;
        }

        pSub1 = p.subtract(ONE);
        qSub1 = q.subtract(ONE);
        phi = pSub1.multiply(qSub1);

        //
        // calculate the private exponent
View Full Code Here

  testBigInteger(BigInteger.valueOf(Long.MAX_VALUE));
  BigInteger max = BigInteger.valueOf(Long.MAX_VALUE).setBit(63);
  testBigInteger(max);
  Random rand = new Random();
  for (int i = 0; i < 1000; i++) {
      testBigInteger(max.subtract(BigInteger.valueOf(Math.abs(rand.nextLong()))));
  }
    }

    public void testBigInteger(BigInteger v) throws Exception {
    }
View Full Code Here

  private BigInteger originalValue = null;
 
  public ULongLong(String uLongLongValue) {
    BigInteger realValue = new BigInteger(uLongLongValue);
    if ((realValue.compareTo(ULongLong.MIN_VALUE) >= 0)&&(realValue.compareTo(ULongLong.MAX_VALUE) <= 0)) {     
      this.shiftedValue = realValue.subtract(ULongLong.SHIFT_VALUE).longValue();
      this.originalValue = new BigInteger(uLongLongValue);
    } else {
      throw new NumberFormatException(uLongLongValue+" is not in the range of (0 to 18,446,744,073,709,551,615).");
    }
  }
View Full Code Here

        BigInteger x = new BigInteger(1, w);

        BigInteger c = x.mod(q.multiply(TWO));

        p = x.subtract(c.subtract(ONE));

        if (p.testBit(size - 1)) {
          if (p.isProbablePrime(certainty)) {
            primesFound = true;
            break;
View Full Code Here

      BigInteger temp = sqrt(b.multiply(b).multiply(d));
      if (b.signum() == -1)
        temp = temp.add(BigInteger.ONE).negate();
      temp = temp.add(a);
      if (temp.signum() == -1)
        temp = temp.subtract(c.subtract(BigInteger.ONE));
      return temp.divide(c);
    }
   
   
    public boolean equals(Object obj) {
View Full Code Here

  public String run() {
    BigInteger ways = partitionAndCount(LENGTH, MAX_COUNT, new ArrayList<Integer>());
   
    // Multiply by (base - 1) / base to discount sequences with leading zeros
    BigInteger BASE_BI = BigInteger.valueOf(BASE);
    ways = ways.multiply(BASE_BI.subtract(BigInteger.ONE));
    ways = divideExactly(ways, BASE_BI);
   
    return ways.toString();
  }
 
View Full Code Here

      BigInteger temp = sqrt(b.multiply(b).multiply(d));
      if (b.signum() == -1)
        temp = temp.add(BigInteger.ONE).negate();
      temp = temp.add(a);
      if (temp.signum() == -1)
        temp = temp.subtract(c.subtract(BigInteger.ONE));
      return temp.divide(c);
    }
   
   
    public boolean equals(Object obj) {
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.