Examples of bitLength()


Examples of com.ericsson.otp.erlang.OtpErlangLong.bitLength()

        new OtpErlangBinary(oos.toByteArray());
    return o;
      } else if (atomValue.equals("bigint")
           && i instanceof OtpErlangLong) {
    final OtpErlangLong l = (OtpErlangLong) i;
    final int w = l.signum() * l.bitLength();
    final OtpErlangLong x = new OtpErlangLong(l.longValue());
    final java.math.BigInteger b = l.bigIntegerValue();
    System.out.println("long: " + l + ": " + w + ": " + b.signum()
      * b.bitLength() + ": " + x + ": " + l.isLong() + ": "
      + l.isULong());
View Full Code Here

Examples of java.math.BigInteger.bitLength()

     * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
     */
    public AsymmetricCipherKeyPair generateKeyPair()
    {
    BigInteger n = params.getN();
    int        nBitLength = n.bitLength();
    BigInteger d;

    do
    {
      d = new BigInteger(nBitLength, random);
View Full Code Here

Examples of java.math.BigInteger.bitLength()

            } else if (BigDecimal.ONE.equals(x)) {
                writeByte((byte) (DECIMAL_0_1 + 1));
            } else {
                int scale = x.scale();
                BigInteger b = x.unscaledValue();
                int bits = b.bitLength();
                if (bits <= 63) {
                    if (scale == 0) {
                        writeByte((byte) DECIMAL_SMALL_0);
                        writeVarLong(b.longValue());
                    } else {
View Full Code Here

Examples of java.math.BigInteger.bitLength()

            } else if (BigDecimal.ONE.equals(x)) {
                return 1;
            }
            int scale = x.scale();
            BigInteger b = x.unscaledValue();
            int bits = b.bitLength();
            if (bits <= 63) {
                if (scale == 0) {
                    return 1 + getVarLongLen(b.longValue());
                }
                return 1 + getVarIntLen(scale) + getVarLongLen(b.longValue());
View Full Code Here

Examples of java.math.BigInteger.bitLength()

      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

Examples of java.math.BigInteger.bitLength()

        * v0:  v = 1/(2*x)
        */
        if (num == Double.POSITIVE_INFINITY)       // d > 1.7E308
        {
            BigInteger bi = numberToBeSquareRooted.unscaledValue();
            int biLen = bi.bitLength();
            int biSqrtLen = biLen / 2;                // floors it too

            bi = bi.shiftRight(biSqrtLen);          // bad guess sqrt(d)
            iteration1 = new BigDecimal(bi);                 // x ~ sqrt(d)

View Full Code Here

Examples of java.math.BigInteger.bitLength()

                            "Argument to SQRT() function must not be negative");
                }
                BigInteger n = x.movePointRight(mc.getPrecision() << 1)
                        .toBigInteger();

                int bits = (n.bitLength() + 1) >> 1;
                BigInteger ix = n.shiftRight(bits);
                BigInteger ixPrev;

                do {
                    ixPrev = ix;
View Full Code Here

Examples of java.math.BigInteger.bitLength()

   
    // The output's mantissa will have 'precision' or fewer bits
    public BigFloat multiply(BigFloat other, int precision, boolean roundUp) {
      BigInteger man = mantissa.multiply(other.mantissa);
      int exp = exponent + other.exponent;
      int excess = man.bitLength() - precision;
      if (excess > 0) {
        if (roundUp) {
          BigInteger mask = BigInteger.ONE.shiftLeft(excess).subtract(BigInteger.ONE);
          if (!mask.and(man).equals(BigInteger.ZERO))
            man = man.add(BigInteger.ONE.shiftLeft(excess));
View Full Code Here

Examples of java.math.BigInteger.bitLength()

    Set<Long> numbers = new HashSet<Long>();
    long max = 0;
    for (int n = 0; n <= 50; n++) {
      for(int k = 0; k <= n; k++) {
        BigInteger x = Library.binomial(n, k);
        if (x.bitLength() >= 64)
          throw new AssertionError("Number too large to handle");
        numbers.add(x.longValue());
        max = Math.max(x.longValue(), max);
      }
    }
View Full Code Here

Examples of java.math.BigInteger.bitLength()

        }
       
        BigInteger norm = norm(mu, lambda);

        // Ceiling of log2 of the norm
        int log2Norm = norm.bitLength();

        // If length(TNAF) > 30, then length(TNAF) < log2Norm + 3.52
        int maxLength = log2Norm > 30 ? log2Norm + 4 : 34;

        // The array holding the TNAF
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.