• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FDBigInteger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中sun.misc.FDBigInteger的典型用法代码示例。如果您正苦于以下问题:Java FDBigInteger类的具体用法?Java FDBigInteger怎么用?Java FDBigInteger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FDBigInteger类属于sun.misc包,在下文中一共展示了FDBigInteger类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCmp

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestFDBigInteger.java


示例2: testLeftInplaceSub

import sun.misc.FDBigInteger; //导入依赖的package包/类
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);
                    }
                }
            }
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TestFDBigInteger.java


示例3: testRightInplaceSub

import sun.misc.FDBigInteger; //导入依赖的package包/类
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;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TestFDBigInteger.java


示例4: testValueOfMulPow52

import sun.misc.FDBigInteger; //导入依赖的package包/类
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 + ")");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TestFDBigInteger.java


示例5: testLeftShift

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TestFDBigInteger.java


示例6: testQuoRemIteration

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TestFDBigInteger.java


示例7: testCmpPow52

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:TestFDBigInteger.java


示例8: testAddAndCmp

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:TestFDBigInteger.java


示例9: testMultBy10

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TestFDBigInteger.java


示例10: testMultByPow52

import sun.misc.FDBigInteger; //导入依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TestFDBigInteger.java



注:本文中的sun.misc.FDBigInteger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TokenScanner类代码示例发布时间:2022-05-22
下一篇:
Java Sessions类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap