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


C++ CBigNum::getuint方法代码示例

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


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

示例1: formatTimeInterval

static QString formatTimeInterval(CBigNum t)
{
    enum  EUnit { YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, NUM_UNITS };

    const int SecondsPerUnit[NUM_UNITS] =
    {
        31556952, // average number of seconds in gregorian year
        31556952/12, // average number of seconds in gregorian month
        24*60*60, // number of seconds in a day
        60*60, // number of seconds in an hour
        60, // number of seconds in a minute
        1
    };

    const char* UnitNames[NUM_UNITS] =
    {
        "year",
        "month",
        "day",
        "hour",
        "minute",
        "second"
    };

    if (t > 0xFFFFFFFF)
    {
        t /= SecondsPerUnit[YEAR];
        return QString("%1 years").arg(t.ToString(10).c_str());
    }
    else
    {
        unsigned int t32 = t.getuint();

        int Values[NUM_UNITS];
        for (int i = 0; i < NUM_UNITS; i++)
        {
            Values[i] = t32/SecondsPerUnit[i];
            t32 %= SecondsPerUnit[i];
        }

        int FirstNonZero = 0;
        while (FirstNonZero < NUM_UNITS && Values[FirstNonZero] == 0)
            FirstNonZero++;

        QString TimeStr;
        for (int i = FirstNonZero; i < std::min(FirstNonZero + 3, (int)NUM_UNITS); i++)
        {
            int Value = Values[i];
            TimeStr += QString("%1 %2%3 ").arg(Value).arg(UnitNames[i]).arg((Value == 1)? "" : "s"); // FIXME: this is English specific
        }
        return TimeStr;
    }
}
开发者ID:BlockPioneers,项目名称:chipcoin-old,代码行数:53,代码来源:miningpage.cpp

示例2: bn

std::string Base58::raw_encode (
    unsigned char const* begin, unsigned char const* end,
        Alphabet const& alphabet, bool withCheck)
{
    CAutoBN_CTX pctx;
    CBigNum bn58 = 58;
    CBigNum bn0 = 0;

    // Convert little endian data to bignum
    CBigNum bn (begin, end);
    std::size_t const size (std::distance (begin, end));

    // Convert bignum to std::string
    std::string str;
    // Expected size increase from base58 conversion is approximately 137%
    // use 138% to be safe
    str.reserve (size * 138 / 100 + 1);
    CBigNum dv;
    CBigNum rem;

    while (bn > bn0)
    {
        if (!BN_div (&dv, &rem, &bn, &bn58, pctx))
            throw bignum_error ("EncodeBase58 : BN_div failed");

        bn = dv;
        unsigned int c = rem.getuint ();
        str += alphabet [c];
    }

    for (const unsigned char* p = end-2; p >= begin && *p == 0; p--)
        str += alphabet [0];

    // Convert little endian std::string to big endian
    reverse (str.begin (), str.end ());
    return str;
}
开发者ID:CCJY,项目名称:rippled,代码行数:37,代码来源:Base58.cpp


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