Java 类sun.misc.FDBigInteger 实例源码

项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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;
    }
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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;
    }
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:TestFDBigInteger.java   
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");
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:TestFDBigInteger.java   
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;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:infobip-open-jdk-8    文件:TestFDBigInteger.java   
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");
}
项目:infobip-open-jdk-8    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:infobip-open-jdk-8    文件:TestFDBigInteger.java   
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;
    }
}
项目:infobip-open-jdk-8    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u-dev-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-dev-jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u-dev-jdk    文件:TestFDBigInteger.java   
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;
    }
}
项目:jdk8u-dev-jdk    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:OLD-OpenJDK8    文件:TestFDBigInteger.java   
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");
}
项目:OLD-OpenJDK8    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:OLD-OpenJDK8    文件:TestFDBigInteger.java   
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;
    }
}
项目:OLD-OpenJDK8    文件:TestFDBigInteger.java   
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);
                    }
                }
            }
        }
    }
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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 + ")");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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);
        }
    }
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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);
        }
    }
}
项目:jdk8u-jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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 + ")");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}
项目:jdk8u_jdk    文件:TestFDBigInteger.java   
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");
}