本文整理汇总了C++中ExprResult::isFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ ExprResult::isFloat方法的具体用法?C++ ExprResult::isFloat怎么用?C++ ExprResult::isFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExprResult
的用法示例。
在下文中一共展示了ExprResult::isFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eval
/* @TODO Implementar melhor, copy paste de SumNode com poucas diferenças */
ExprResult ModNode::eval()
{
ExprResult result;
ExprResult left = mLeft->eval();
ExprResult right = mRight->eval();
if (left.isNumeric() && right.isNumeric())
{
if (left.isInteger())
{
long leftValue = left.getIntegerValue();
long resultValue;
if (right.isInteger())
{
long rightValue = right.getIntegerValue();
resultValue = leftValue % rightValue;
result.setValue("long", resultValue);
}
else if (right.isFloat())
{
long rightValue = (long)right.getFloatValue();
resultValue = leftValue % rightValue;
result.setValue("long", resultValue);
}
}
else if (left.isFloat())
{
long leftValue = (long)left.getFloatValue();
long resultValue;
if (right.isInteger())
{
long rightValue = right.getIntegerValue();
resultValue = leftValue % rightValue;
}
else if (right.isFloat())
{
long rightValue = (long)right.getFloatValue();
resultValue = leftValue % rightValue;
}
result.setValue("long", resultValue);
}
}
// Nenhuma operação pode ser realizada
if (result.getType() == "void")
{
Log::fatal("Uso de módulo com valores não numéricos");
}
return result;
}
示例2: eval
ExprResult SumNode::eval()
{
ExprResult result;
ExprResult left = mLeft->eval();
ExprResult right = mRight->eval();
if (left.isNumeric() && right.isNumeric())
{
if (left.isInteger())
{
long leftValue = left.getIntegerValue();
if (right.isInteger())
{
long rightValue = right.getIntegerValue();
long resultValue = leftValue + rightValue;
result.setValue(result.getLargerType(left, right), resultValue);
}
else if (right.isFloat())
{
double rightValue = right.getFloatValue();
double resultValue = leftValue + rightValue;
result.setValue(result.getLargerType(left, right), resultValue);
}
}
else if (left.isFloat())
{
double leftValue = left.getFloatValue();
double resultValue = leftValue;
if (right.isInteger())
{
long rightValue = right.getIntegerValue();
resultValue += rightValue;
}
else if (right.isFloat())
{
double rightValue = right.getFloatValue();
resultValue += rightValue;
}
result.setValue(result.getLargerType(left, right), resultValue);
}
}
// Nenhuma operação pode ser realizada
if (result.getType() == "void")
{
Log::fatal("Uso de soma com valores não numéricos");
}
return result;
}