当前位置: 首页>>代码示例>>C++>>正文


C++ BigNumber::add方法代码示例

本文整理汇总了C++中BigNumber::add方法的典型用法代码示例。如果您正苦于以下问题:C++ BigNumber::add方法的具体用法?C++ BigNumber::add怎么用?C++ BigNumber::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigNumber的用法示例。


在下文中一共展示了BigNumber::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: evalNode

            void evalNode(BigNumber &n, int i, DdValues<BigNumber, ARITY> const &values)
            {
                assert(size_t(i) <= pools.size());

                if (BDD) {
                    int w = tmp1.store(0);

                    for (int b = 0; b < ARITY; ++b) {
                        tmp2.store(values.get(b));
                        tmp2.shiftLeft(i - values.getLevel(b) - 1);
                        w = tmp1.add(tmp2);
                    }

                    n.setArray(pools[i].template allocate<uint64_t>(w));
                    n.store(tmp1);
                } else {
                    int w;

                    if (ARITY <= 0) {
                        w = tmp1.store(0);
                    } else {
                        w = tmp1.store(values.get(0));

                        for (int b = 1; b < ARITY; ++b) {
                            w = tmp1.add(values.get(b));
                        }
                    }

                    n.setArray(pools[i].template allocate<uint64_t>(w));
                    n.store(tmp1);
                }
            }
开发者ID:DanielKowalczyk1984,项目名称:WCTimpl,代码行数:32,代码来源:Cardinality.hpp

示例2: evalNode

 void evalNode(BigNumber& n,
               int i,
               DdValues<BigNumber,ARITY> const& values) {
     assert(0 <= i && size_t(i) <= pools.size());
     if (BDD) {
         size_t w = tmp1.store(0);
         for (int b = 0; b < ARITY; ++b) {
             tmp2.store(values.get(b));
             int k = i - values.getLevel(b) - 1;
             if (ARITY == 2) {
                 tmp2.shiftLeft(k);
             }
             else {
                 while (--k >= 0) {
                     tmp3.store(tmp2);
                     for (int b = 1; b < ARITY; ++b) {
                         tmp2.add(tmp3);
                     }
                 }
             }
             w = tmp1.add(tmp2);
         }
         n.setArray(pools[i].allocate<uint64_t>(w));
         n.store(tmp1);
     }
     else {
         size_t w;
         if (ARITY <= 0) {
             w = tmp1.store(0);
         }
         else {
             w = tmp1.store(values.get(0));
             for (int b = 1; b < ARITY; ++b) {
                 w = tmp1.add(values.get(b));
             }
         }
         n.setArray(pools[i].allocate<uint64_t>(w));
         n.store(tmp1);
     }
 }
开发者ID:pombredanne,项目名称:TdZdd,代码行数:40,代码来源:Cardinality.hpp

示例3: main

int main() {
    assert(BigNumber(6, 9).toString() == "6.9");
    assert(BigNumber(3).toString() == "3");
    assert(BigNumber(-5).toString() == "-5");

    vector<string> v = {"10", "10.3", "-10.555", "69.34433434", "0", "2"};

    for (int i = 0; i < v.size(); i++)
        assert(BigNumber(v[i]).toString() == v[i]);


    BigNumber nineteen = BigNumber(19);
    nineteen.plus_one();
    assert(nineteen.toString() == "20");

    BigNumber x = BigNumber(8);
    x.plus_one();
    assert(x.toString() == "9");
    x.plus_one();
    assert(x.toString() == "10");
    BigNumber y = BigNumber("10.6");
    y.plus_one();
    assert(y.toString() == "11.6");

    BigNumber ten = BigNumber("5.1");
    ten.add(BigNumber("3.2"));
    assert(ten.toString() == "8.3");
    ten.add(BigNumber("1.12"));
    assert(ten.toString() == "9.42");
    ten.add(BigNumber("0.1"));
    assert(ten.toString() == "9.52");
    ten.add(BigNumber("0.000001"));
    assert(ten.toString() == "9.520001");

    return 0;
}
开发者ID:palcu,项目名称:bignumber-complex-cpp,代码行数:36,代码来源:main.cpp

示例4: solve

BigNumber solve(int l, int b, int p) {
    for (int i = 0; i <= l; ++i)
        for (int j = 0; j <= p; ++j)
            dp[i][j] = BigNumberZ;
 
    dp[1][0] = BigNumber(b);
    for (int i = 2; i <= l; ++i) {
        for (int k = 0; k <= p; ++k) {
            dp[i][0].add(dp[i - 1][k] * b);
            if (k != 0)
                dp[i][k] = dp[i - 1][k - 1];
        }
    }
    BigNumber rez;
        for (int k = 0; k <= p; ++k)
            rez.add(dp[l][k]);   
    return rez;
}
开发者ID:vladpaunescu,项目名称:algorithms,代码行数:18,代码来源:zero_1.cpp

示例5: getValue

 std::string getValue(BigNumber const& n) {
     if (BDD) {
         tmp2.store(n);
         int k = numVars - topLevel;
         if (ARITY == 2) {
             tmp2.shiftLeft(k);
         }
         else {
             while (--k >= 0) {
                 tmp3.store(tmp2);
                 for (int b = 1; b < ARITY; ++b) {
                     tmp2.add(tmp3);
                 }
             }
         }
         return tmp2;
     }
     else {
         return n;
     }
 }
开发者ID:pombredanne,项目名称:TdZdd,代码行数:21,代码来源:Cardinality.hpp


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