Package java.math

Examples of java.math.BigInteger.testBit()


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


        else
        {
            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);
    }
View Full Code Here

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

        else
        {
            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);
    }
View Full Code Here

    bb.position(0);
    bb.limit(8);
    BigInteger bi = Unsigned.getUnsignedLong(bb);
    BigInteger uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());

    bb = ByteBuffer.allocate(10);
View Full Code Here

    bb.limit(8);
    BigInteger bi = Unsigned.getUnsignedLong(bb);
    BigInteger uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());

    bb = ByteBuffer.allocate(10);
    bb.put((byte)0x00);
View Full Code Here

    bb.position(0);
    bb.limit(10);
    bi = Unsigned.getUnsignedLong(bb, 1);
    uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());
  }
View Full Code Here

    bb.limit(10);
    bi = Unsigned.getUnsignedLong(bb, 1);
    uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());
  }

  /**
 
View Full Code Here

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

        else
        {
            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);
    }
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.