本文整理汇总了C++中bigint类的典型用法代码示例。如果您正苦于以下问题:C++ bigint类的具体用法?C++ bigint怎么用?C++ bigint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了bigint类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
bool operator==(const bigint &lhs, const std::string &rhs)
{
std::string slhs = lhs.dtos(lhs.deq);
return (slhs == rhs);
}
开发者ID:tugotron,项目名称:BigNumbers,代码行数:5,代码来源:bigint.cpp
示例2: gcd
friend bigint gcd(const bigint &a, const bigint &b) {
return b.isZero() ? a : gcd(b, a % b);
}
开发者ID:aqfaridi,项目名称:Competitve-Programming-Codes,代码行数:3,代码来源:TR004.cpp
示例3: main
//.........这里部分代码省略.........
} else if (endswith(outfilename, ".mc")) {
outputismc = 1 ;
#ifdef ZLIB
} else if (endswith(outfilename, ".rle.gz")) {
outputgzip = 1 ;
} else if (endswith(outfilename, ".mc.gz")) {
outputismc = 1 ;
outputgzip = 1 ;
#endif
} else {
lifefatal("Output filename must end with .rle or .mc.") ;
}
if (strlen(outfilename) > 200)
lifefatal("Output filename too long") ;
}
if (timeline && hyper)
lifefatal("Cannot use both timeline and exponentially increasing steps") ;
imp = createUniverse() ;
if (progress)
lifeerrors::seterrorhandler(&progerrors_instance) ;
else
lifeerrors::seterrorhandler(&stderrors_instance) ;
if (verbose) {
hlifealgo::setVerbose(1) ;
}
imp->setMaxMemory(maxmem) ;
#ifdef TIMING
timestamp() ;
#endif
if (testscript) {
if (argc > 1) {
filename = argv[1] ;
const char *err = readpattern(argv[1], *imp) ;
if (err) lifefatal(err) ;
}
runtestscript(testscript) ;
}
filename = argv[1] ;
const char *err = readpattern(argv[1], *imp) ;
if (err) lifefatal(err) ;
if (liferule) {
err = imp->setrule(liferule) ;
if (err) lifefatal(err) ;
}
bool boundedgrid = (imp->gridwd > 0 || imp->gridht > 0) ;
if (boundedgrid) {
hyper = 0 ;
inc = 1 ; // only step by 1
}
if (inc != 0)
imp->setIncrement(inc) ;
if (timeline) {
int lowbit = inc.lowbitset() ;
bigint t = 1 ;
for (int i=0; i<lowbit; i++)
t.mul_smallint(2) ;
if (t != inc)
lifefatal("Bad increment for timeline") ;
imp->startrecording(2, lowbit) ;
}
int fc = 0 ;
for (;;) {
if (quiet < 2) {
cout << imp->getGeneration().tostring() ;
if (!quiet)
cout << ": " << imp->getPopulation().tostring() << endl ;
else
cout << endl ;
}
if (popcount)
imp->getPopulation() ;
if (autofit)
imp->fit(viewport, 1) ;
if (render)
imp->draw(viewport, renderer) ;
if (maxgen >= 0 && imp->getGeneration() >= maxgen)
break ;
if (!hyper && maxgen > 0 && inc == 0) {
bigint diff = maxgen ;
diff -= imp->getGeneration() ;
int bs = diff.lowbitset() ;
diff = 1 ;
diff <<= bs ;
imp->setIncrement(diff) ;
}
if (boundedgrid && !imp->CreateBorderCells()) break ;
imp->step() ;
if (boundedgrid && !imp->DeleteBorderCells()) break ;
if (timeline) imp->extendtimeline() ;
if (maxgen < 0 && outfilename != 0)
writepat(fc++) ;
if (timeline && imp->getframecount() + 2 > MAX_FRAME_COUNT)
imp->pruneframes() ;
if (hyper)
imp->setIncrement(imp->getGeneration()) ;
}
if (maxgen >= 0 && outfilename != 0)
writepat(-1) ;
exit(0) ;
}
开发者ID:re-curse,项目名称:golly,代码行数:101,代码来源:bgolly.cpp
示例4: to_bigint
void to_bigint(string &s, bigint &n) {
for (int i = s.size()-1; i >= 0; i--) {
n.push_back(s[i] - '0');
}
}
开发者ID:ChinaLongGanHu,项目名称:Coding,代码行数:5,代码来源:MultiplyStrings.cpp
示例5: doresize
void doresize(bigint &ret, const bigint &lhs, const bigint &rhs)
{
unsigned int size = rhs.getWidth() > lhs.getWidth() ? rhs.getWidth() : lhs.getWidth();
if (ret.getWidth() < size)
ret.resize(size);
}
开发者ID:phyrrus9,项目名称:bigint,代码行数:6,代码来源:arithmatichelpers.cpp
示例6: export_srp_params
str
export_srp_params (const bigint &N, const bigint &g)
{
return strbuf ("N=0x") << N.getstr (16) << ",g=0x" << g.getstr (16);
}
开发者ID:Sidnicious,项目名称:sfslite,代码行数:5,代码来源:serial.C
注:本文中的bigint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论