Examples of shiftRight()


Examples of java.math.BigInteger.shiftRight()

        boolean remainder;
        if (left.compareTo(right) < 0)
        {
            BigInteger sum = left.add(right);
            remainder = sum.testBit(0);
            midpoint = sum.shiftRight(1);
        }
        else
        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
            BigInteger distance = max.add(right).subtract(left);
            remainder = distance.testBit(0);
            midpoint = distance.shiftRight(1).add(left).mod(max);
        }
        return new Pair(midpoint, remainder);
    }

    public static byte[] toByteArray(int i)
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

        boolean remainder;
        if (left.compareTo(right) < 0)
        {
            BigInteger sum = left.add(right);
            remainder = sum.testBit(0);
            midpoint = sum.shiftRight(1);
        }
        else
        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
            BigInteger distance = max.add(right).subtract(left);
            remainder = distance.testBit(0);
            midpoint = distance.shiftRight(1).add(left).mod(max);
        }
        return new Pair(midpoint, remainder);
    }

    public static byte[] toByteArray(int i)
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

     * signifFloor the top SIGNIFICAND_BITS + 1.
     *
     * It helps to consider the real number signif = absX * 2^(SIGNIFICAND_BITS - exponent).
     */
    int shift = exponent - SIGNIFICAND_BITS - 1;
    long twiceSignifFloor = absX.shiftRight(shift).longValue();
    long signifFloor = twiceSignifFloor >> 1;
    signifFloor &= SIGNIFICAND_MASK; // remove the implied bit

    /*
     * We round up if either the fractional part of signif is strictly greater than 0.5 (which is
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

        boolean remainder;
        if (left.compareTo(right) < 0)
        {
            BigInteger sum = left.add(right);
            remainder = sum.testBit(0);
            midpoint = sum.shiftRight(1);
        }
        else
        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

        {
            BigInteger max = TWO.pow(sigbits);
            // wrapping case
            BigInteger distance = max.add(right).subtract(left);
            remainder = distance.testBit(0);
            midpoint = distance.shiftRight(1).add(left).mod(max);
        }
        return Pair.create(midpoint, remainder);
    }

    public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2)
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

  public void test (TestHarness harness)
  {
    harness.checkPoint ("shift");
    BigInteger x =
      new BigInteger ("-50123044517898350982301255831878893568", 10);
    harness.check (x.shiftRight(64).toString(), "-2717175687894652269");
    harness.check (x.shiftLeft(-64).toString(), "-2717175687894652269");
    harness.check (x.shiftRight(1).toString(),
      "-25061522258949175491150627915939446784");
    harness.check (x.shiftLeft(1).toString(),
      "-100246089035796701964602511663757787136");
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

    harness.checkPoint ("shift");
    BigInteger x =
      new BigInteger ("-50123044517898350982301255831878893568", 10);
    harness.check (x.shiftRight(64).toString(), "-2717175687894652269");
    harness.check (x.shiftLeft(-64).toString(), "-2717175687894652269");
    harness.check (x.shiftRight(1).toString(),
      "-25061522258949175491150627915939446784");
    harness.check (x.shiftLeft(1).toString(),
      "-100246089035796701964602511663757787136");

    harness.check (x.shiftRight(0).toString(), x.toString());
View Full Code Here

Examples of java.math.BigInteger.shiftRight()

    harness.check (x.shiftRight(1).toString(),
      "-25061522258949175491150627915939446784");
    harness.check (x.shiftLeft(1).toString(),
      "-100246089035796701964602511663757787136");

    harness.check (x.shiftRight(0).toString(), x.toString());
    harness.check (x.shiftLeft(0).toString(), x.toString());

    x = new BigInteger ("50123044517898350982301255831878893568", 10);
    harness.check (x.shiftRight(64).toString(), "2717175687894652268");
    harness.check (x.shiftLeft(-64).toString(), "2717175687894652268");
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.