本文整理汇总了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;
}
}
示例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;
}