Package java.math

Examples of java.math.BigInteger.shiftLeft()


      throw new NullPointerException("ba");

    BigInteger hash = BigInteger.ZERO;

    for (byte b : ba)
      hash = hash.shiftLeft(5).add(hash).add(new BigInteger(Integer.toString(0xFF & b)));

    return new UnsignedLong(hash);
  }

  /**
 
View Full Code Here


      throw new NullPointerException("ba");

    BigInteger hash = BigInteger.ZERO;

    for (byte b : ba)
      hash = hash.shiftLeft(5).add(hash).add(new BigInteger(Integer.toString(0xFF & b)));

    return new UnsignedInteger(hash);
  }

  /**
 
View Full Code Here

      throw new NullPointerException("ba");

    BigInteger hash = BigInteger.ZERO;

    for (byte b : ba)
      hash = hash.shiftLeft(5).add(hash).add(new BigInteger(Integer.toString(0xFF & b)));

    // blanks msb
    return new UnsignedInteger(hash.and(new BigInteger("16777215")));
  }
View Full Code Here

    UnsignedShort hash = new UnsignedShort("5381");

    for (byte b : ba)
    {
      BigInteger bi = hash.bigIntegerValue();
      hash = new UnsignedShort(bi.shiftLeft(5).add(bi).add(new BigInteger(Integer.toString(0xFF & b))));
    }

    return hash;
  }
}
View Full Code Here

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
View Full Code Here

                mhi = BigInteger.valueOf(1<<Log2P);
            }

            b = b.shiftLeft(e[0] + s2);
            BigInteger s = BigInteger.valueOf(1);
            s = s.shiftLeft(s2);
            /* At this point we have the following:
             *   s = 2^s2;
             *   1 > df = b/2^s2 > 0;
             *   (d - prevDouble(d))/2 = mlo/2^s2;
             *   (nextDouble(d) - d)/2 = mhi/2^s2. */
 
View Full Code Here

            m2 += i;
            s2 += i;
        }
        /* Now S*2^s2 has exactly four leading zero bits in its most significant word. */
        if (b2 > 0)
            b = b.shiftLeft(b2);
        if (s2 > 0)
            S = S.shiftLeft(s2);
        /* Now we have d/10^k = b/S and
           (mhi * 2^m2) / S = maximum acceptable error, divided by 10^k. */
        if (k_check) {
View Full Code Here

                            && ((word1(d) & 1) == 0)
                    )) {
                    if (j1 > 0) {
                        /* Either dig or dig+1 would work here as the least significant decimal digit.
                           Use whichever would produce a decimal value closer to d. */
                        b = b.shiftLeft(1);
                        j1 = b.compareTo(S);
                        if (((j1 > 0) || (j1 == 0 && (((dig & 1) == 1) || biasUp)))
                            && (dig++ == '9')) {
                                buf.append('9');
                                if (roundOff(buf)) {
View Full Code Here

                b = b.multiply(BigInteger.valueOf(10));
            }

        /* Round off last digit */

        b = b.shiftLeft(1);
        j = b.compareTo(S);
        if ((j > 0) || (j == 0 && (((dig & 1) == 1) || biasUp))) {
//        roundoff:
//            while(*--s == '9')
//                if (s == buf) {
View Full Code Here

        BigInteger big = BigInteger.ZERO;
        for (int i = 0; i < str.length(); i++)
        {
            int charpos = 16 * (sigchars - (i + 1));
            BigInteger charbig = BigInteger.valueOf(str.charAt(i) & 0xFFFF);
            big = big.or(charbig.shiftLeft(charpos));
        }
        return big;
    }

    /**
 
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.