Package java.math

Examples of java.math.BigInteger.subtract()


            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


      if (argCount == 2)
        sum = sum.negate();

      if (term instanceof LispBignum)
        sum = sum.subtract(((LispBignum)term).getBigIntegerValue());
      else // (term instanceof LispInteger)
        sum = sum.subtract(BigInteger.valueOf(((LispInteger)term).getLongValue()));

      args = args.cdr();
    };
View Full Code Here

        sum = sum.negate();

      if (term instanceof LispBignum)
        sum = sum.subtract(((LispBignum)term).getBigIntegerValue());
      else // (term instanceof LispInteger)
        sum = sum.subtract(BigInteger.valueOf(((LispInteger)term).getLongValue()));

      args = args.cdr();
    };

View Full Code Here

            byte [] prependHeader = {1, 0};
            BigInteger bigLastRow = new BigInteger(Bytes.add(prependHeader, lastPadded));
            if (bigLastRow.compareTo(bigEnd_) > 0) {
                return progressSoFar_;
            }
            BigDecimal processed = new BigDecimal(bigLastRow.subtract(bigStart_));
            try {
                BigDecimal progress = processed.setScale(3).divide(bigRange_, BigDecimal.ROUND_HALF_DOWN);
                progressSoFar_ = progress.floatValue();
                return progressSoFar_;
            } catch (java.lang.ArithmeticException e) {
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 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

                    if (bd.compareTo(BigDecimal.ZERO)>0)
                        bi=bi.add(BigInteger.ONE);
                }
                else {
                    if (bd.compareTo(BigDecimal.ZERO)<0)
                        bi=bi.subtract(BigInteger.ONE);
                }
                int biBitCount=bi.bitCount();
                if (biBitCount<=32)
                    return bi.intValue();
                else if (biBitCount<=64)
View Full Code Here

                    if (numerator.compareTo(BigDecimal.ZERO)>0)
                        quotient=quotient.add(BigInteger.ONE);
                }
                else {
                    if (numerator.compareTo(BigDecimal.ZERO)<0)
                        quotient=quotient.subtract(BigInteger.ONE);
                }
                int quotientBitCount=quotient.bitCount();
                if (quotientBitCount<=32)
                    return quotient.intValue();
                else if (quotientBitCount<=64)
View Full Code Here

        else
        {
            // wrapping case
            BigInteger distance = MD5_MAX.add(right).subtract(left);
            BigInteger unchecked = distance.divide(TWO).add(left);
            midpoint = (unchecked.compareTo(MD5_MAX) > 0) ? unchecked.subtract(MD5_MAX) : unchecked;
        }
        return new BigIntegerToken(midpoint);
    }

  public BigIntegerToken getMinimumToken()
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

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.