Package java.math

Examples of java.math.BigInteger.bitLength()


        ECPublicKeyParameters pubKey = (ECPublicKeyParameters)key;
        BigInteger n = pubKey.getParameters().getN();
        int nBitLength = n.bitLength();
       
        BigInteger e = new BigInteger(1, digest);
        int eBitLength = e.bitLength();
       
        if (eBitLength > nBitLength)
        {
            throw new DataLengthException("input too large for ECNR key.");
        }
View Full Code Here


        BigInteger val = new BigInteger(remainder);
        if (negative) {
            // 2's complement
            val = val.add(BigInteger.valueOf(-1)).not();
        }
        if (val.bitLength() > 63) {
            throw new IllegalArgumentException("At offset " + offset + ", "
                                               + length + " byte binary number"
                                               + " exceeds maximum signed long"
                                               + " value");
        }
View Full Code Here

                        return ~position;  // '+' must be parsed if minWidth exceeded
                    }
                }
            }
            if (totalBig != null) {
                if (totalBig.bitLength() > 63) {
                    // overflow, parse 1 less digit
                    totalBig = totalBig.divide(BigInteger.TEN);
                    pos--;
                }
                return setValue(context, totalBig.longValue(), position, pos);
View Full Code Here

            BigInteger h = e.multiply(BigInteger.valueOf(3));

            ECPoint R = this;

            for (int i = h.bitLength() - 2; i > 0; i--)
            {            
                R = R.twice();      

                if ( h.testBit(i) && !e.testBit(i) )
                {                   
View Full Code Here

    } else if (in.scale() < 0) {
      // should this cast to a string and call putStringRef()?
      throw new IllegalArgumentException(
          "VT_DECIMAL only supports a minimum scale of 0 and the passed"
              + " in value has a scale of " + in.scale());
    } else if (allWordBigInt.bitLength() > 12 * 8) {
      throw new IllegalArgumentException(
          "VT_DECIMAL supports a maximum of "
              + 12
              * 8
              + " bits not counting scale and the number passed in has "
View Full Code Here

      throw new IllegalArgumentException(
          "VT_DECIMAL supports a maximum of "
              + 12
              * 8
              + " bits not counting scale and the number passed in has "
              + allWordBigInt.bitLength());

    } else {
      // no bounds problem to be handled
    }

View Full Code Here

    validateDecimalMinMax(destinationDecimal);
    // First limit the number of digits and then the precision.
    // Try and round to 29 digits because we can sometimes do that
    BigInteger allWordBigInt;
    allWordBigInt = destinationDecimal.unscaledValue();
    if (allWordBigInt.bitLength() > 96) {
      destinationDecimal = destinationDecimal.round(new MathContext(29));
      // see if 29 digits uses more than 96 bits
      if (allWordBigInt.bitLength() > 96) {
        // Dang. It was over 97 bits so shorten it one more digit to
        // stay <= 96 bits
View Full Code Here

    BigInteger allWordBigInt;
    allWordBigInt = destinationDecimal.unscaledValue();
    if (allWordBigInt.bitLength() > 96) {
      destinationDecimal = destinationDecimal.round(new MathContext(29));
      // see if 29 digits uses more than 96 bits
      if (allWordBigInt.bitLength() > 96) {
        // Dang. It was over 97 bits so shorten it one more digit to
        // stay <= 96 bits
        destinationDecimal = destinationDecimal.round(new MathContext(
            28));
      }
View Full Code Here

        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)
View Full Code Here

      BigDecimal x = null, e = null;              // initial x:  x0 ~ sqrt()
      BigDecimal v = null, g = null;              // initial v:  v0 = 1/(2*x)

      // Estimate the square root with the foremost 62 bits of squarD
      BigInteger bi = squarD.unscaledValue();     // bi and scale are a tandem
      int biLen = bi.bitLength();
      int shift = Math.max(0, biLen - BITS + (biLen%2 == 0 ? 0 : 1));   // even shift..
      bi = bi.shiftRight(shift);                  // ..floors to 62 or 63 bit BigInteger

      double root = Math.sqrt(bi.doubleValue());
      BigDecimal halfBack = new BigDecimal(BigInteger.ONE.shiftLeft(shift/2));
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.