sun.misc.FDBigInteger Java Examples

The following examples show how to use sun.misc.FDBigInteger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestFDBigInteger.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void testCmp(FDBigInteger t, FDBigInteger o) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bo = o.toBigInteger();
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmp returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
    if (o.cmp(t) != -cmp) {
        throw new Exception("asymmetrical cmp");
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
}
 
Example #2
Source File: TestFDBigInteger.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testRightInplaceSub(left, right, false);
                        right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        right.makeImmutable();
                        testRightInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #3
Source File: TestFDBigInteger.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testRightInplaceSub(left, right, false);
                        right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        right.makeImmutable();
                        testRightInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #4
Source File: TestFDBigInteger.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception {
    BigInteger biLeft = left.toBigInteger();
    BigInteger biRight = right.toBigInteger();
    FDBigInteger diff = left.rightInplaceSub(right);
    if (!isImmutable && diff != right) {
        throw new Exception("rightInplaceSub of doesn't reuse its argument");
    }
    check(biLeft, left, "leftInplaceSub corrupts its left argument");
    if (isImmutable) {
        check(biRight, right, "leftInplaceSub corrupts its right immutable argument");
    }
    try {
        check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result");
    } catch (Exception e) {
        System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight));
        throw e;
    }
}
 
Example #5
Source File: TestFDBigInteger.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCmp(FDBigInteger t, FDBigInteger o) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bo = o.toBigInteger();
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmp returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
    if (o.cmp(t) != -cmp) {
        throw new Exception("asymmetrical cmp");
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
}
 
Example #6
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception {
    BigInteger biLeft = left.toBigInteger();
    BigInteger biRight = right.toBigInteger();
    FDBigInteger diff = left.rightInplaceSub(right);
    if (!isImmutable && diff != right) {
        throw new Exception("rightInplaceSub of doesn't reuse its argument");
    }
    check(biLeft, left, "leftInplaceSub corrupts its left argument");
    if (isImmutable) {
        check(biRight, right, "leftInplaceSub corrupts its right immutable argument");
    }
    try {
        check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result");
    } catch (Exception e) {
        System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight));
        throw e;
    }
}
 
Example #7
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testLeftInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testLeftInplaceSub(left, right, false);
                        left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        left.makeImmutable();
                        testLeftInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #8
Source File: TestFDBigInteger.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testRightInplaceSub(left, right, false);
                        right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        right.makeImmutable();
                        testRightInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #9
Source File: TestFDBigInteger.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testRightInplaceSub(left, right, false);
                        right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        right.makeImmutable();
                        testRightInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #10
Source File: TestFDBigInteger.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void testRightInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception {
    BigInteger biLeft = left.toBigInteger();
    BigInteger biRight = right.toBigInteger();
    FDBigInteger diff = left.rightInplaceSub(right);
    if (!isImmutable && diff != right) {
        throw new Exception("rightInplaceSub of doesn't reuse its argument");
    }
    check(biLeft, left, "leftInplaceSub corrupts its left argument");
    if (isImmutable) {
        check(biRight, right, "leftInplaceSub corrupts its right immutable argument");
    }
    try {
        check(biLeft.subtract(biRight), diff, "rightInplaceSub returns wrong result");
    } catch (Exception e) {
        System.out.println(biLeft+" - "+biRight+" = "+biLeft.subtract(biRight));
        throw e;
    }
}
 
Example #11
Source File: TestFDBigInteger.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testLeftInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testLeftInplaceSub(left, right, false);
                        left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        left.makeImmutable();
                        testLeftInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #12
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testCmp(FDBigInteger t, FDBigInteger o) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bo = o.toBigInteger();
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmp returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
    if (o.cmp(t) != -cmp) {
        throw new Exception("asymmetrical cmp");
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
}
 
Example #13
Source File: TestFDBigInteger.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testLeftInplaceSub() throws Exception {
        for (int p5 = 0; p5 <= MAX_P5; p5++) {
            for (int p2 = 0; p2 <= MAX_P2; p2++) {
//                for (int p5r = 0; p5r <= p5; p5r += 10) {
//                    for (int p2r = 0; p2r <= p2; p2r += 10) {
                for (int p5r = 0; p5r <= p5; p5r++) {
                    for (int p2r = 0; p2r <= p2; p2r++) {
                        // This strange way of creating a value ensures that it is mutable.
                        FDBigInteger left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        FDBigInteger right = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5r, p2r);
                        testLeftInplaceSub(left, right, false);
                        left = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
                        left.makeImmutable();
                        testLeftInplaceSub(left, right, true);
                    }
                }
            }
        }
    }
 
Example #14
Source File: TestFDBigInteger.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void testCmp(FDBigInteger t, FDBigInteger o) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bo = o.toBigInteger();
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmp returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
    if (o.cmp(t) != -cmp) {
        throw new Exception("asymmetrical cmp");
    }
    check(bt, t, "cmp corrupts this");
    check(bo, o, "cmp corrupts other");
}
 
Example #15
Source File: TestFDBigInteger.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultByPow52() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultByPow52(value, p5, p2);
        }
    }
}
 
Example #16
Source File: TestFDBigInteger.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testCmpPow52(FDBigInteger t, int p5, int p2) throws Exception {
    FDBigInteger o = FDBigInteger.valueOfPow52(p5, p2);
    BigInteger bt = t.toBigInteger();
    BigInteger bo = biPow52(p5, p2);
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmpPow52 returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmpPow52 corrupts this");
    check(bo, o, "cmpPow5 corrupts other");
}
 
Example #17
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultByPow52(FDBigInteger t, int p5, int p2) throws Exception {
    BigInteger bt = t.toBigInteger();
    FDBigInteger r = t.multByPow52(p5, p2);
    if (bt.signum() == 0 && r != t) {
        throw new Exception("multByPow52 of doesn't reuse its argument");
    }
    check(bt.multiply(biPow52(p5, p2)), r, "multByPow52 returns wrong result");
}
 
Example #18
Source File: TestFDBigInteger.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultBy10(FDBigInteger t, boolean isImmutable) throws Exception {
    BigInteger bt = t.toBigInteger();
    FDBigInteger r = t.multBy10();
    if ((bt.signum() == 0 || !isImmutable) && r != t) {
        throw new Exception("multBy10 of doesn't reuse its argument");
    }
    if (isImmutable) {
        check(bt, t, "multBy10 corrupts its argument");
    }
    check(bt.multiply(BigInteger.TEN), r, "multBy10 returns wrong result");
}
 
Example #19
Source File: TestFDBigInteger.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testCmpPow52(FDBigInteger t, int p5, int p2) throws Exception {
    FDBigInteger o = FDBigInteger.valueOfPow52(p5, p2);
    BigInteger bt = t.toBigInteger();
    BigInteger bo = biPow52(p5, p2);
    int cmp = t.cmp(o);
    int bcmp = bt.compareTo(bo);
    if (bcmp != cmp) {
        throw new Exception("cmpPow52 returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "cmpPow52 corrupts this");
    check(bo, o, "cmpPow5 corrupts other");
}
 
Example #20
Source File: TestFDBigInteger.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultBy10() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultBy10(value, false);
            value.makeImmutable();
            testMultBy10(value, true);
        }
    }
}
 
Example #21
Source File: TestFDBigInteger.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultBy10() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultBy10(value, false);
            value.makeImmutable();
            testMultBy10(value, true);
        }
    }
}
 
Example #22
Source File: TestFDBigInteger.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testQuoRemIteration(FDBigInteger t, FDBigInteger s) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bs = s.toBigInteger();
    int q = t.quoRemIteration(s);
    BigInteger[] qr = bt.divideAndRemainder(bs);
    if (!BigInteger.valueOf(q).equals(qr[0])) {
        throw new Exception("quoRemIteration returns incorrect quo");
    }
    check(qr[1].multiply(BigInteger.TEN), t, "quoRemIteration returns incorrect rem");
}
 
Example #23
Source File: TestFDBigInteger.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultByPow52() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultByPow52(value, p5, p2);
        }
    }
}
 
Example #24
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testAddAndCmp(FDBigInteger t, FDBigInteger x, FDBigInteger y) throws Exception {
    BigInteger bt = t.toBigInteger();
    BigInteger bx = x.toBigInteger();
    BigInteger by = y.toBigInteger();
    int cmp = t.addAndCmp(x, y);
    int bcmp = bt.compareTo(bx.add(by));
    if (bcmp != cmp) {
        throw new Exception("addAndCmp returns " + cmp + " expected " + bcmp);
    }
    check(bt, t, "addAndCmp corrupts this");
    check(bx, x, "addAndCmp corrupts x");
    check(by, y, "addAndCmp corrupts y");
}
 
Example #25
Source File: TestFDBigInteger.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testValueOfMulPow52(long value, int p5, int p2) throws Exception {
    BigInteger bi = BigInteger.valueOf(value & ~LONG_SIGN_MASK);
    if (value < 0) {
        bi = bi.setBit(63);
    }
    check(biPow52(p5, p2).multiply(bi), FDBigInteger.valueOfMulPow52(value, p5, p2),
            "valueOfMulPow52(" + Long.toHexString(value) + "." + p5 + "," + p2 + ")");
}
 
Example #26
Source File: TestFDBigInteger.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testLeftInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception {
    BigInteger biLeft = left.toBigInteger();
    BigInteger biRight = right.toBigInteger();
    FDBigInteger diff = left.leftInplaceSub(right);
    if (!isImmutable && diff != left) {
        throw new Exception("leftInplaceSub of doesn't reuse its argument");
    }
    if (isImmutable) {
        check(biLeft, left, "leftInplaceSub corrupts its left immutable argument");
    }
    check(biRight, right, "leftInplaceSub corrupts its right argument");
    check(biLeft.subtract(biRight), diff, "leftInplaceSub returns wrong result");
}
 
Example #27
Source File: TestFDBigInteger.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultBy10() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultBy10(value, false);
            value.makeImmutable();
            testMultBy10(value, true);
        }
    }
}
 
Example #28
Source File: TestFDBigInteger.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void testLeftInplaceSub(FDBigInteger left, FDBigInteger right, boolean isImmutable) throws Exception {
    BigInteger biLeft = left.toBigInteger();
    BigInteger biRight = right.toBigInteger();
    FDBigInteger diff = left.leftInplaceSub(right);
    if (!isImmutable && diff != left) {
        throw new Exception("leftInplaceSub of doesn't reuse its argument");
    }
    if (isImmutable) {
        check(biLeft, left, "leftInplaceSub corrupts its left immutable argument");
    }
    check(biRight, right, "leftInplaceSub corrupts its right argument");
    check(biLeft.subtract(biRight), diff, "leftInplaceSub returns wrong result");
}
 
Example #29
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testLeftShift(FDBigInteger t, int shift, boolean isImmutable) throws Exception {
    BigInteger bt = t.toBigInteger();
    FDBigInteger r = t.leftShift(shift);
    if ((bt.signum() == 0 || shift == 0 || !isImmutable) && r != t) {
        throw new Exception("leftShift doesn't reuse its argument");
    }
    if (isImmutable) {
        check(bt, t, "leftShift corrupts its argument");
    }
    check(bt.shiftLeft(shift), r, "leftShift returns wrong result");
}
 
Example #30
Source File: TestFDBigInteger.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testMultBy10() throws Exception {
    for (int p5 = 0; p5 <= MAX_P5; p5++) {
        for (int p2 = 0; p2 <= MAX_P2; p2++) {
            // This strange way of creating a value ensures that it is mutable.
            FDBigInteger value = FDBigInteger.valueOfPow52(0, 0).multByPow52(p5, p2);
            testMultBy10(value, false);
            value.makeImmutable();
            testMultBy10(value, true);
        }
    }
}