本文整理汇总了C++中Double::getDig方法的典型用法代码示例。如果您正苦于以下问题:C++ Double::getDig方法的具体用法?C++ Double::getDig怎么用?C++ Double::getDig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Double
的用法示例。
在下文中一共展示了Double::getDig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
void Double::operator -=(const Double other)
{
int rate = digs - other.getDig();
if(rate == 0){
lv -= other.getlv();
// if(digs > 2){
// lv = reduce(lv,digs-2);
// digs=2;
// }
}
else{
int rates=1;
int c = abs(rate);
for(int i = 0; i < c; ++i)
rates *= 10;
if(rate > 0)
lv -= other.getlv()*rates;
else{
lv *= rates;
lv -= other.getlv();
}
//lv = reduce(lv,c);
digs = max(digs,other.getDig());
}
}
示例2: reduce
void Double::operator *=(const Double other)
{
lv *= other.getlv();
lv = reduce(lv,digs+other.getDig()-2);
digs = 2;
}
示例3: adjustValue
bool Double::operator <=(const Double &other) const
{
int rate = digs - other.getDig();
if(rate == 0)
return lv <= other.getlv();
qint64 v1=lv,v2=other.getlv();
adjustValue(rate,v1,v2);
return v1<=v2;
}
示例4: Double
Double Double::operator *(const Double &other) const
{
qint64 v;
int rate = digs - other.getDig();
if(rate == 0){
v = getlv() * other.getlv();
}
else{
int rates=1;
int c = abs(rate);
for(int i = 0; i < c; ++i)
rates *= 10;
if(rate > 0)
v = getlv() * (other.getlv()*rates);
else
v = (lv*rates) * other.getlv();
}
v = reduce(v,max(digs,other.getDig())*2-2);
return Double(v,2);
}