本文整理汇总了C++中TVar::asDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ TVar::asDouble方法的具体用法?C++ TVar::asDouble怎么用?C++ TVar::asDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVar
的用法示例。
在下文中一共展示了TVar::asDouble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompAB
bool CompAB(const TVar& a, const TVar& b, TVarFuncCmp fcmp)
{
bool r = true;
__int64 bi;
double bd;
switch (a.vType)
{
case vtUnknown:
case vtInteger:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.inum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.inum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.asString()))
{
case tsStr: r = fcmp(vtString,a.asString().data(),b.str.data()); break;
case tsInt: bi=b.asInteger(); r = fcmp(vtInteger,&a.inum,&bi); break;
case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtDouble:
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = fcmp(vtInteger,&a.dnum,&b.inum); break;
case vtDouble: r = fcmp(vtDouble,&a.dnum,&b.dnum); break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = fcmp(vtString,a.asString().data(),b.str.data()); break;
case tsInt:
case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd); break;
}
break;
}
}
break;
case vtString:
{
r = fcmp(vtString,a.asString().data(),b.asString().data());
break;
}
}
return r;
};
示例2: if
TVar operator%(const TVar& a, const TVar& b)
{
TVar r;
switch (a.vType)
{
case vtUnknown:
case vtInteger:
{
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = b.inum ? (a.inum % b.inum) : 0; break;
case vtDouble: r = fabs(b.dnum) > DBL_EPSILON? fmod((double)a.inum, b.dnum) : 0.0; break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = a; break;
case tsInt:
{
__int64 bi=b.asInteger();
r = bi ? a.inum % bi : 0; break;
}
case tsFloat:
{
double bd=b.asDouble();
r = fabs(bd) > DBL_EPSILON? fmod((double)a.inum, bd) : 0.0; break;
}
}
break;
}
}
break;
}
case vtDouble:
{
switch (b.vType)
{
case vtUnknown:
case vtInteger: r = b.inum ? fmod(a.dnum,(double)b.inum) : 0.0; break;
case vtDouble: r = fabs(b.dnum) > DBL_EPSILON? fmod(a.dnum,b.dnum) : 0.0; break;
case vtString:
{
switch (checkTypeString(b.str))
{
case tsStr: r = a; break;
case tsInt:
case tsFloat:
{
double bd=b.asDouble();
r = fabs(bd) > DBL_EPSILON? fmod(a.dnum, bd) : 0.0; break;
}
}
break;
}
}
break;
}
case vtString:
{
TypeString tsA=checkTypeString(a.str),tsB;
if (b.vType == vtInteger || b.vType == vtUnknown)
tsB=tsInt;
else if (b.vType == vtDouble)
tsB=tsFloat;
else
tsA=tsB=tsStr;
if ((tsA == tsStr && tsB == tsStr) || (tsA != tsStr && tsB == tsStr) || (tsA == tsStr && tsB != tsStr))
r = a;
else if (tsA == tsInt && tsB == tsInt)
{
__int64 bi=b.asInteger();
r = bi ? (a.asInteger() % bi) : 0;
}
else
{
double bd=b.asDouble();
r = fabs(bd) > DBL_EPSILON? fmod(a.asDouble() , bd) : 0.0;
}
break;
}
}
return r;
};